如何在VS Code终端的PowerShell中将提示符改为(pyside2) PS <路径>>
修改PowerShell提示符为
(pyside2) PS <path>> 临时生效(仅当前终端会话)
在VS Code的PowerShell终端中直接执行以下命令,回车后提示符立即变更,但关闭终端后会恢复默认:
function prompt { "(pyside2) PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) " }
永久生效(所有PowerShell会话,包含VS Code终端)
- 检查PowerShell配置文件是否存在:
若返回Test-Path $PROFILEFalse,执行以下命令创建配置文件:New-Item -Path $PROFILE -ItemType File -Force - 打开配置文件进行编辑:
notepad $PROFILE - 在记事本中添加以下代码并保存:
function prompt { "(pyside2) PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) " } - 重启VS Code终端或PowerShell,新提示符即可永久生效。
内容的提问来源于stack exchange,提问作者Ezel Amadies
相关产品推荐
相关产品推荐

