最新的vscode中修改默认的终端为Git Bash

Posted 是小橙鸭丶

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了最新的vscode中修改默认的终端为Git Bash相关的知识,希望对你有一定的参考价值。

在windows下,我们有些npm项目需要执行bash脚本,如果每次都是从文件夹通过“Git Bash Here”打开的话,我们的效率会变得极其低,所以我们要将vscode的终端配置为Git Bash,我们之前的老版本直接在settings.json配置以下内容即可

// "terminal.integrated.automationShell.windows": "",
// "terminal.integrated.shell.windows": "自己电脑的bash路径"

2021年6月12日更新

VSCode更新后,之前的配置会提示错误:

此项已弃用,配置默认 shell 的新推荐方法是在 `#terminal.integrated.profiles.windows#` 中创建一个终端配置文件,并将其配置文件名称设置为 `#terminal.integrated.defaultProfile.windows#` 中的默认值。此操作当前将优先于新的配置文件设置,但将来会发生更改。(2)终端在 Windows 上使用的 shell 的路径。详细了解如何配置 shell。

注意:以前的terminal.integrated.shell.windows已经废弃。

新方法

参考官方文档,修改配置文件,将下面的配置加到 setting.json文件。

"terminal.integrated.profiles.windows": 
        "PowerShell -NoProfile": 
          "source": "PowerShell",
          "args": [
            "-NoProfile"
          ]
        ,
   "Git-Bash": 
          "path": "D:\\\\Git\\\\Git\\\\bin\\\\bash.exe(自己的bash路径)",
          "args": []
      
 ,
"terminal.integrated.defaultProfile.windows": "Git-Bash",
// "terminal.integrated.automationShell.windows": "", //废弃不要的
// "terminal.integrated.shell.windows": "D:\\\\Git\\\\Git\\\\bin\\\\bash.exe"//废弃不要的

配置完毕后,重启VSCODE,即完成效果如下

把它变回CMD终端

1.首先打开vscode里面的设置选项,搜索 shell 找到此选项

"terminal.integrated.shell.windows": "C:\\\\Windows\\\\System32\\\\cmd.exe"

 

以上是关于最新的vscode中修改默认的终端为Git Bash的主要内容,如果未能解决你的问题,请参考以下文章

vscode (v1.57.0) 配置默认终端为git bash

在VSCODE中将git bash设置为默认终端[重复]

VSCode修改默认终端

win vscode 配置默认终端为 anaconda

Git Bash 未在 VSCode 中显示为终端选项

VSCode的集成终端默认是cmd,要自己手动改成bash