我在Windows 10电脑上使用Visual Studio Code。我想把我的默认终端从Windows PowerShell更改为Ubuntu上的Bash(在Windows上)。
我该怎么做呢?
我在Windows 10电脑上使用Visual Studio Code。我想把我的默认终端从Windows PowerShell更改为Ubuntu上的Bash(在Windows上)。
我该怎么做呢?
当前回答
离开@arielhad的解决方案…
我的VSCode版本是1.57.1。
打开settings.xml文件:
Ctrl + Shift + p 输入“Open Settings (JSON)”并选择。
增加如下内容:
"terminal.integrated.profiles.windows": {
"PowerShell": {
"path": [
"${env:windir}\\Sysnative\\WindowsPowerShell\\v1.0\\powershell.exe",
"${env:windir}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
],
"source": "PowerShell",
"icon": "terminal-powershell",
"args": [
"-NoLogo",
"-ExecutionPolicy",
"Bypass"
]
},
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"icon": "terminal-cmd"
},
//START: THIS DOES NOT WORK
"Git Bash": {
"path": [
"C:\\Program Files\\Git\\bin\\bash.exe",
],
"source": "Git Bash",
"icon": "terminal-bash"
}
// END: THIS DOES NOT WORK
//START: THIS WORKS
"GitBash": {
"path": [
"C:\\Program Files\\Git\\bin\\bash.exe",
],
"icon": "terminal-bash"
}
// END: THIS WORKS
}
我不知道为什么第二种方法有效,但它确实有效。“Git Bash”似乎是一个保留名称,我猜你不能设置路径。
其他回答
只需按Ctrl + Shift +p 搜索“终端:选择默认配置文件”单击 您将看到终端选项并选择Git Bash
我只是在打开的终端中键入以下关键字;
powershell bash cmd 节点 Python(或python3)
详见下图。(VSCode版本1.19.1 - windows 10操作系统)
它也适用于VS Code Mac。我尝试用VSCode(版本1.20.1)
转到>首选项>设置文件(或按Ctrl+,),然后点击右上角最左边的图标,“打开设置(JSON)”
在JSON设置窗口中,添加这个(在花括号{}内):
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\bash.exe"`
(在这里你可以放任何其他你想要的自定义设置)
签出该路径以确保bash.exe文件在那里,否则请找出它的位置并指向该路径。
现在如果你在VS Code中打开一个新的终端窗口,它应该用bash而不是PowerShell打开。
要在Visual Studio Code中更改项目的默认终端:
创建一个名为.vscode的文件夹 创建一个设置。Json文件: 写下你想要的设置
例如,如果你是一个窗口用户,想要设置“命令提示符”作为默认终端,你可以这样写:
"terminal.integrated.defaultProfile.windows": "Command Prompt"
你可以传递:“Git Bash”,“PowerShell”和“命令提示符”。
对于Linux,你将使用terminal.integrated.defaultProfile.linux,对于mac系统,你将使用:terminal.integrated.defaultProfile.osx
通过运行terminal: Select default Profile命令配置您的默认集成终端,该命令也可以通过terminal下拉菜单访问。
看到https://code.visualstudio.com/docs/editor/integrated-terminal _terminal-profiles