且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 VS Code 中更改默认终端

更新时间:2022-12-06 11:40:44

github 上有很多关于这个的问题,参见例如 默认控制台从升级期间我想要的 Powershell 更改(我认为这是 v1.60 版本的最旧跟踪).

There are a lot of issues on github about this, see, e,g, Default console changed from what I wanted to Powershell during upgrade ( I think that is oldest tracking one for the v1.60 release).

我可以在 Stable v1.60 版本上复制该问题,但在具有完全相同设置的 Insiders 版本上不能.

I can replicate the problem on the Stable v1.60 build but not on the Insiders' Build with the exact same settings.

所以这不是你的设置,我相信 vscode 团队知道这一点.您的选择是

So it isn't your set-up and I'm sure the vscode team is aware of it. Your options are to

(1) 使用 Insiders' Build - 至少对我有用,
(2) 将 vscode 降级到 v1.59,
(3) 当我点击 Add Terminal + 按钮时,我会得到默认的 Git Bash 终端,或者
(4) 重命名您的默认配置文件 - 见下文.

(1) use the Insiders' Build - at least that works for me,
(2) downgrade vscode to v1.59,
(3) when I click the Add Terminal + button I do get my default Git Bash terminal, or
(4) rename your default profile - see below.

仅供参考,我的设置:

  "terminal.integrated.profiles.windows": {
    "PowerShell": {
      "source": "PowerShell",
      "icon": "terminal-powershell"
    },
    "Command Prompt": {
      "path": [
        "${env:windir}\\Sysnative\\cmd.exe",
        "${env:windir}\\System32\\cmd.exe"
      ],
      "args": [],
      "icon": "terminal-cmd"
    },
    // "Git Bash": {  // "Git Bash" does not work
    "GitBash": {      // "GitBash" does work
      "path": "C:\\Program Files\\Git\\bin\\bash.exe",
      "icon": "terminal-bash"
    }
  },


  //  "terminal.integrated.defaultProfile.windows": "Git Bash"  // does not work for me
  "terminal.integrated.defaultProfile.windows": "GitBash"  // does work


  // deprecated but may still work for you
  // "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"

以前尝试将 Git Bash 设置为默认配置文件,对于 Git Bash 建议使用 GitBash 代替(删除空格).直到 今天 在 v1.60 稳定版中,这对我来说从来没有用过.

Previously trying to set Git Bash as default profile, for Git Bash it was suggested to use GitBash instead (remove the space). That never worked for me until today in the v1.60 Stable Build.

因此,如果不起作用,可以尝试将您的个人资料名称更改为 Git BashWSL 以外的名称.

So might try changing your profile name to something other than Git Bash or WSL, etc, if that isn't working.