我在Windows 10电脑上使用Visual Studio Code。我想把我的默认终端从Windows PowerShell更改为Ubuntu上的Bash(在Windows上)。
我该怎么做呢?
我在Windows 10电脑上使用Visual Studio Code。我想把我的默认终端从Windows PowerShell更改为Ubuntu上的Bash(在Windows上)。
我该怎么做呢?
当前回答
只需按Ctrl + Shift +p 搜索“终端:选择默认配置文件”单击 您将看到终端选项并选择Git Bash
其他回答
整合的壳选项仍然有效,但已经贬值。解决方法是使用集成配置文件:
"terminal.integrated.defaultProfile.windows": "C:\\Program Files\\Git\\bin\\bash.exe (migrated)",
"terminal.integrated.profiles.windows": {
"C:\\Program Files\\Git\\bin\\bash.exe (migrated)": {
"path": "C:\\Program Files\\Git\\bin\\bash.exe",
"args": []
}
}
通过运行terminal: Select default Profile命令配置您的默认集成终端,该命令也可以通过terminal下拉菜单访问。
看到https://code.visualstudio.com/docs/editor/integrated-terminal _terminal-profiles
离开@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”似乎是一个保留名称,我猜你不能设置路径。
如果你想要选择控制台的类型,你可以把它写在“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 SHIFT P打开命令面板来更改终端
或者你可以点击顶部的“查看”,然后点击“打开命令面板”
然后输入Terminal:选择Default Profile
然后你输入你想要哪个终端。