Windows上的Visual Studio Code默认使用PowerShell作为集成终端。如果你想从Visual Studio Code中使用Bash,应该遵循哪些步骤?
当前回答
在最新的稳定版本中,即1.54,禁用ConPTY解决了我的问题。我写这篇文章是希望它也能解决你的问题。
{
"terminal.integrated.shell.windows": "C:\\path\\to\\bin\\bash.exe",
"terminal.integrated.windowsEnableConpty": false
}
其他回答
按住Ctrl + '打开终端。 在终端中,输入bash在终端中使用Git bash。 注意:确保在您的机器上安装了Git Bash。
如果您想再次使用PowerShell,只需在终端中输入PowerShell即可。要使用Windows命令行,在终端中输入cmd。
您选择的设置将被用作默认设置。
VSCODE 1.63.2
即使把这里的答案结合起来,我也不能让它工作。也许,我有一个奇异的设置。我会得到这个错误,设置"terminal.integrated.defaultProfile.windows": "Git Bash",它仍然只会打开Powershell, Git Bash无处可见:
我的解决方法是修改命令提示符的入口,通过改变它指向bash的路径,然后将其设置为默认值,如下所示:
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": [
"C:\\Path\\To\\Git\\bin\\bash.exe",
// "${env:windir}\\Sysnative\\cmd.exe",
// "${env:windir}\\System32\\cmd.exe"
],
"args": [],
"icon": "terminal-cmd"
},
"terminal.integrated.defaultProfile.windows": "Command Prompt",
我跟随Paul DeCarlo的教程使用了Windows子系统for Linux (WSL)中的Bash,而不是Git Bash for Windows附带的Bash。它们与上面答案中的步骤相同,但在用户设置中使用下面的步骤。
“终端集成windows shell。”。“C: \ windows \ sysnative \ \ bash . exe”,
这对我来说第一次奏效了。这对这种物质来说很少见。
我恰好是一家财富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"
}
您不再需要手动输入bash.exe路径。这个答案不赞成。现在,如果在默认路径中安装了git,可以直接切换到bash。如果将git安装到不同的路径,则需要使用下面的解决方案。
从https://git-scm.com/download/win安装Git。
然后打开Visual Studio Code,使用Ctrl + Shift + p打开命令面板,然后输入“open user setting”,然后从下拉菜单中选择“open user Settings”。
然后这个选项卡会打开,左边是默认设置,右边是你的设置:
现在将这行代码复制到您自己的设置页面(右侧的窗格)并保存 "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
注意:“C:\\Program Files\Git\bin\bash.exe”是Git安装时bash.exe文件所在的路径。如果您使用的是Windows子系统for Linux (WSL) Bash shell,路径将是“C:\Windows\System32\ Bash .exe”
现在按Ctrl + '从Visual Studio Code打开终端。你会有巴斯
推荐文章
- 如何设置每个文件类型的标签大小?
- 我如何添加环境变量启动。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 "