在 VS Code 中添加 Git Bash 终端集成
最近重装了 vscode 和 git,发现在 vscode 中无法直接使用 git bash 终端。估计是因为没装到默认路径或者没添加 path 导致 vscode 找不到 git bash。
解决方法
在 vscode 的 setting.json
中添加相应的设置即可。
ctrl + ,
打开Settings
页面。- 搜索
@feature:terminal profile window
- 找到
Terminal › Integrated › Profiles: Windows
, - 选择
Edit in settings.json
- 搜索
在
settings.json
文件中,向"terminal.integrated.profiles.windows": { }
对象中新增 git bash 的设置。1
2
3
4
5"Git Bash": {
"source": "Git Bash", // A profile source that will auto detect the paths to the shell. Note that non-standard executable locations are not supported and must be created manually in a new profile.
"path": "D:\\Scoop\\apps\\git\\current\\bin\\bash.exe", // A single path to a shell executable or an array of paths that will be used as fallbacks when one fails.
"icon": "terminal-bash" // A codicon ID to associate with the terminal icon.
}其中起作用的
path
属性,source
和icon
属性可删除,icon
也可以设置为自己喜欢的图标。
注意将path
属性设置为你自己的路径。一般位于......\\git\\bin\\bash.exe
保存设置后,应该就能在新建终端选项中看到 git bash 了。如果没有,则检查
path
属性的路径是否正确。如果有需要,可通过
Terminal › Integrated › Default Profile: Windows
将 git bash 设置为默认终端。