如何配置VS Code(Windows)使用Ubuntu应用作为终端

5

我在Windows 10上安装了Ubuntu应用程序,并希望将其作为VS Code的终端使用。我发现VS Code自动检测到像Git Bash、PowerShell、Cmd.exe这样的选项,并提供使用它们作为终端的选项。但我想使用Ubuntu,这可行吗?

2个回答

4
针对使用Ubuntu发行版,您只需要在cmd中输入一个简单的命令来更改wsl使用的默认发行版为ubuntu。在cmd中键入wslconfig /setdefault Ubuntu即可。
然后,在我的电脑上,vscode给了我选择要使用哪个终端的选项,因此我选择了wsl bash,因此它编辑了用户设置"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\bash.exe"在Preferences->settings中。上述代码覆盖了默认设置。
您的电脑可能有不同的路径,请参考stackoverflow link to configure vscode for wsl as terminal
您还可以参考微软链接进行wsl配置https://learn.microsoft.com/en-us/windows/wsl/wsl-config
您可以参考similar question as yours for ubuntu and multiple distros

1
我已按以下方式配置了VS Code,以便将其用作“集成终端”。
"terminal.integrated.profiles.windows": {
    "Ubuntu (WSL)": {
        "path": "wsl.exe",
        "args": ["-d", "ubuntu"]
    }
},
...

Integrated Terminal WSL


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接