2021年了, 如何将 Git Bash 设置为 VSCode 的终端?

今天打开 VSCode 准备撸代码,打开终端,结果发现原来配置的 bash 不能用了,只有 PowerShell 和 Command Prompt。这让人很不舒适,于是网上搜罗了一番了,可惜都是些陈芝麻烂谷子,没一个能用的。

原来我们是用的 "terminal.integrated.shell.windows" 来配置终端的,但是在 2021 年 4 月已经弃用了这个字段,现在要用最新的 "terminal.integrated.profiles.windows" 来配置,配置如下:

// settings.json
{
    // 终端配置
  "terminal.integrated.profiles.windows": {
    "PowerShell": {
      "source": "PowerShell",
      "icon": "terminal-powershell"
    },
    "Command Prompt": {
      "path": [
        "${env:windir}\\Sysnative\\cmd.exe",
        "${env:windir}\\System32\\cmd.exe"
      ],
      "icon": "terminal-cmd"
    },
    "GitBash": {
      "path": ["C:\\Program Files\\Git\\bin\\bash.exe"],
      "icon": "terminal-bash"
    },
  },
  "terminal.integrated.defaultProfile.windows": "GitBash",
}

详细步骤:

  1. 打开“设置” Untitled.png

  2. 在搜索框中搜索:terminal.integrated.profiles.windows Untitled 1.png

  3. 点击下方:在 settings.json 中编辑,进入到 settings.json 文件

    之后将终端配置写进去,之后请看第 4 步。

    注意:

    a. "terminal.integrated.defaultProfile.windows": "GitBash" 这一条设置后,就会在打开终端后,默认使用 bash 作为终端了;

    b. Git Bash 的路径请填你自己电脑上 bash.exe 的位置。

  4. 最后,务必重启 VSCode 编辑器,然后打开终端重试即可。


参考:dev.to/andrewriver…

添加我的微信:enjoy_Mr_cat,共同成长,卷卷群里等你 🤪。

以上,感谢您的阅读~

posted @ 2021-09-09 11:53  见嘉于世  阅读(0)  评论(0编辑  收藏  举报  来源