我在Windows 10电脑上使用Visual Studio Code。我想把我的默认终端从Windows PowerShell更改为Ubuntu上的Bash(在Windows上)。

我该怎么做呢?


当前回答

要在Visual Studio Code中更改项目的默认终端:

创建一个名为.vscode的文件夹 创建一个设置。Json文件: 写下你想要的设置

例如,如果你是一个窗口用户,想要设置“命令提示符”作为默认终端,你可以这样写:

"terminal.integrated.defaultProfile.windows": "Command Prompt"

你可以传递:“Git Bash”,“PowerShell”和“命令提示符”。

对于Linux,你将使用terminal.integrated.defaultProfile.linux,对于mac系统,你将使用:terminal.integrated.defaultProfile.osx

其他回答

只需按Ctrl + Shift +p 搜索“终端:选择默认配置文件”单击 您将看到终端选项并选择Git Bash

如果你想要选择控制台的类型,你可以把它写在“keybinding”文件中。(该文件可以在以下路径“文件->首选项->键盘快捷键”中找到) `

//with this you can select what type of console you want
{
    "key": "ctrl+shift+t",
    "command": "shellLauncher.launch"
},

//and this will help you quickly change console
{ 
    "key": "ctrl+shift+j", 
    "command": "workbench.action.terminal.focusNext" 
},
{
    "key": "ctrl+shift+k", 
    "command": "workbench.action.terminal.focusPrevious" 
}`

转到>首选项>设置文件(或按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