转载自 vscode中内置集成终端显示为git(bash.exe) (opens new window)
TIPS
背景
VSCode的终端默认是 cmd,有时候在终端中想用下 Linux 中的命令不得行
打开终端设置
- 左下角的齿轮
- Ctrl + `
- 左上角: 文件 > 首选项 > 设置
- Ctrl + Shift + P,然后在里面搜
- 在终端里面选择配置终端设置
- ...
进入
setting.json修改终端
把
terminal.integrated.shell.windows的值改成Git安装目录中的bash.exe路径(要双斜杠),如:"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"1然后重启,打开终端(快捷键 Ctrl + ~ )就是
git-bashTIPS
在
setting.json中还有一个属性terminal.integrated.automationShell.windows,它的说明是:一个路径,设置后将替代 terminal.integrated.shell.windows,并忽略与自动化相关的终端使用情况(例如任务和调试)的 shellArgs 值。比如设置为:
"terminal.integrated.automationShell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"1但是试了没效果,启动还是
cmd,输入bash还报错,可能是设置的不对吧,不晓得啥子原因2021年9月,突然发先新版本VSCode使用上述配置失效,终端启动默认为
powershell,在VSCode升级至1.57.1(2021.6.17)时:此项已弃用,配置默认 shell 的新推荐方法是在
#terminal.integrated.profiles.windows#中创建一个终端配置文件,并将其配置文件名称设置为#terminal.integrated.defaultProfile.windows#中的默认值。此操作当前将优先于新的配置文件设置,但将来会发生更改。{ "terminal.integrated.profiles.windows": { "Git Bash": { "path": "C:\\Program Files\\Git\\bin\\bash.exe", } }, "terminal.integrated.defaultProfile.windows": "Git Bash", }1
2
3
4
5
6
7
8如果
terminal.integrated.defaultProfile.windows的选项中已经有了Git Bash,则无需再配置terminal.integrated.profiles.windows切换终端
- 切换成
cmd:在终端中输入cmd - 切换成
powershell:在终端中输入powershell - 切换成
git-bash:在终端中输入bash
- 切换成