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

我该怎么做呢?


当前回答

按ctrl + Shift + p ->类型的settings.json 在文件的末尾将powershell改为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打开。

整合的壳选项仍然有效,但已经贬值。解决方法是使用集成配置文件:

    "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": []
        }
    }

离开@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打开命令面板来更改终端

或者你可以点击顶部的“查看”,然后点击“打开命令面板”

然后输入Terminal:选择Default Profile

然后你输入你想要哪个终端。