Windows上的Visual Studio Code默认使用PowerShell作为集成终端。如果你想从Visual Studio Code中使用Bash,应该遵循哪些步骤?
当前回答
要在Visual Studio Code中打开终端,你不需要在任何地方都使用推荐的Ctrl + ',因为这是非常不方便的手指操作。更好的解决方案是:
Ctrl + j
其他回答
我跟随Paul DeCarlo的教程使用了Windows子系统for Linux (WSL)中的Bash,而不是Git Bash for Windows附带的Bash。它们与上面答案中的步骤相同,但在用户设置中使用下面的步骤。
“终端集成windows shell。”。“C: \ windows \ sysnative \ \ bash . exe”,
这对我来说第一次奏效了。这对这种物质来说很少见。
在最新的稳定版本中,即1.54,禁用ConPTY解决了我的问题。我写这篇文章是希望它也能解决你的问题。
{
"terminal.integrated.shell.windows": "C:\\path\\to\\bin\\bash.exe",
"terminal.integrated.windowsEnableConpty": false
}
从https://git-scm.com/download/win安装Git 打开Visual Studio Code,按住Ctrl + '打开终端。 使用Ctrl + Shift + P打开命令面板。 类型—选择“默认配置文件” 从选项中选择Git Bash 单击终端窗口中的+图标 新终端现在将是Git Bash终端。给它几秒钟来加载Git Bash 现在,您还可以从terminal中的下拉菜单在不同的终端之间切换。
更新:(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。
对于scoop用户:
"terminal.integrated.shell.windows": "C:\\Users\\[YOUR-NAME]\\scoop\\apps\\git\\current\\usr\\bin\\bash.exe",
"terminal.integrated.shellArgs.windows": [
"-l",
"-i"
],
推荐文章
- 如何设置每个文件类型的标签大小?
- 我如何添加环境变量启动。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 "