Windows上的Visual Studio Code默认使用PowerShell作为集成终端。如果你想从Visual Studio Code中使用Bash,应该遵循哪些步骤?
当前回答
将Git\bin目录添加到Path环境变量中。默认目录为%ProgramFiles%\Git\bin。通过这种方式,你可以在每个终端(包括Visual Studio Code的集成终端)中输入Bash即可访问Git Bash。
Windows下如何设置路径和环境变量
其他回答
按住Ctrl + '打开终端。 在终端中,输入bash在终端中使用Git bash。 注意:确保在您的机器上安装了Git Bash。
如果您想再次使用PowerShell,只需在终端中输入PowerShell即可。要使用Windows命令行,在终端中输入cmd。
您选择的设置将被用作默认设置。
我尝试了上面的答案,因为vscode 1.42.1和他们的工作,让我一个git bash终端。因此,这个设置只适用于从终端打开bash shell:
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
然而,它也有一个不想要的副作用,即它也是用于构建东西的shell,这打破了MS c++链,因为用于路径分隔符的\字符被bash理解为转义字符。对我来说,完整的修复需要我添加这个额外的变量,将其设置为powershell:
"terminal.integrated.automationShell.windows": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
现在,我可以有我的bash终端和Ctrl-Shift-B或F5工作没有问题。
哦,正如其他海报提到的,这些信息的来源是VSCode的文档。
将此添加到settings.json中
{
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "Git Bash",
"icon": "terminal-bash"
},
我恰好是一家财富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"
}
从https://git-scm.com/download/win安装Git 打开Visual Studio Code,按住Ctrl + '打开终端。 使用Ctrl + Shift + P打开命令面板。 类型—选择“默认配置文件” 从选项中选择Git Bash 单击终端窗口中的+图标 新终端现在将是Git Bash终端。给它几秒钟来加载Git Bash 现在,您还可以从terminal中的下拉菜单在不同的终端之间切换。
推荐文章
- 如何设置每个文件类型的标签大小?
- 我如何添加环境变量启动。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 "