Windows上的Visual Studio Code默认使用PowerShell作为集成终端。如果你想从Visual Studio Code中使用Bash,应该遵循哪些步骤?
当前回答
更新:(2022年6月,VsCode 1.67)
这里的许多答案(就像这个,高度好评)依赖于设置“terminal.integrated.shell.windows”,现在已经弃用了。
还有许多其他的(被接受的)假设Git for Windows在PATH中安装bash.exe -这不是目前推荐/默认的安装选项。
我现在的食谱是:
添加以下到您的设置(Ctrl-Shift-P ->首选项:打开设置(JSON)),替换为您自己的bash路径:
"terminal.integrated.profiles.windows": {
"GitBash": {
"path": "C:\\devel\\Git\\bin\\bash.exe",
"icon": "terminal-bash"
}
},
"terminal.integrated.defaultProfile.windows": "GitBash",
关闭当前终端,重新启动VsCode。
其他回答
由于Visual Studio Code的最新更新,事情发生了一些变化。下面的步骤对我有用。
按Ctrl + Shift + P打开Visual Studio Code命令菜单。 在文本区输入>preferences: Open Settings (JSON)。 在JSON文件的末尾添加以下行 右边窗格。 "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe" 关闭并重新打开Visual Studio Code实例。
我恰好是一家财富500强公司的顾问,不幸的是,我用的是Windows 7,没有管理员权限。因此,Node.js, Npm, Visual Studio Code等。被推到我的机器-我不能改变很多,等等…
对于这台运行Windows 7的电脑:
下面是我的新设置。不工作的将被注释掉。
{
"update.channel": "none",
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
//"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\bash.exe"
}
简单地进入设置。在visual studio代码中添加Json,并添加这一行:
"terminal.integrated.defaultProfile.windows": "Git Bash",
将此添加到settings.json中
{
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "Git Bash",
"icon": "terminal-bash"
},
(2021, VSC v.1.55.1)
如何添加Git Bash为默认终端,对于那些安装他们的Git Bash不是在默认路径:
在Visual Studio Code中使用Ctrl +打开设置, a)在“搜索设置”(截图中红框)字段类型为“集成自动化” b)或直接点击功能->终端(ss上的蓝框) 单击settings.json中的任意编辑 将bash.exe的位置输入到"terminal.integrated.shell.windows": " "字段中
注1:由于它是一个JSON文件,请记住在路径中使用双\\而不是\。
注意2:不要混淆bash.exe(它在bin文件夹中)和git-bash.exe,在第一种情况下bash终端将留在VSC中,第二种情况下它将在外部打开。
推荐文章
- 如何设置每个文件类型的标签大小?
- 我如何添加环境变量启动。VSCode中的json
- 如何格式化Visual Studio Code项目中的所有文件?
- Pylint在Visual Studio代码中“未解决的导入”错误
- 如何在VS Code中默认打开文本换行
- Git bash错误:无法fork子进程:没有可用的终端(-1)
- 在Visual Studio代码中更改突出显示文本的颜色
- Visual studio代码-键盘快捷键-全部展开/折叠
- Visual Studio Code无法检测已安装的Git
- 禁用Visual Studio代码中的工具提示提示
- Visual Studio Code -将空格转换为制表符
- 在VSCode中的列自动硬换行
- Visual Studio Code:格式没有使用缩进设置
- 如何排除文件扩展名和语言从“格式保存”在VSCode?
- Visual Studio代码- URI的目标不存在" package:flutter/material.dart "