如何更改 VS Code 中的默认终端

Nen*_*vic 27 terminal visual-studio-code

每当我在 VS Code 中打开终端时,它总是会打开默认终端,而且我总是必须手动更改它。

在此输入图像描述

这真的很烦人,因为我每天都在使用终端。我检查了Terminal工具栏中的设置,但找不到更改默认值的选项。我们怎样才能做到呢?

Nen*_*vic 36

打开终端后,用户应单击右上角的down-arrow按钮,然后会出现一个选项菜单。然后你应该选择Select Default Profile,你可以从那里选择你的默认终端。

在此输入图像描述


Mar*_*ark 9

github 上有很多关于此问题的问题,请参阅,例如,默认控制台在升级过程中从我想要的更改为 Powershell (我认为这是 v1.60 版本中最早的跟踪问题)。

我可以在稳定版 v1.60 版本上复制该问题,但不能在具有完全相同设置的 Insiders 版本上复制该问题。

所以这不是你的设置,我确信 vscode 团队知道这一点。你的选择是

(1) 使用 Insiders' Build - 至少对我有用,
(2) 将 vscode 降级到 v1.59,
(3) 当我单击按钮时,Add Terminal +我确实获得了默认的 Git Bash 终端,或者
(4) 重命名您的默认终端简介 - 见下文。

仅供参考,我的设置:

  "terminal.integrated.profiles.windows": {
    "PowerShell": {
      "source": "PowerShell",
      "icon": "terminal-powershell"
    },
    "Command Prompt": {
      "path": [
        "${env:windir}\\Sysnative\\cmd.exe",
        "${env:windir}\\System32\\cmd.exe"
      ],
      "args": [],
      "icon": "terminal-cmd"
    },
    // "Git Bash": {  // "Git Bash" does not work
    "GitBash": {      // "GitBash" does work
      "path": "C:\\Program Files\\Git\\bin\\bash.exe",
      "icon": "terminal-bash"
    }
  },


  //  "terminal.integrated.defaultProfile.windows": "Git Bash"  // does not work for me
  "terminal.integrated.defaultProfile.windows": "GitBash"  // does work


  // deprecated but may still work for you
  // "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
Run Code Online (Sandbox Code Playgroud)

之前尝试将 Git Bash 设置为默认配置文件,因为Git Bash建议使用它GitBash(删除空格)。直到今天在 v1.60 稳定版本中,这对我来说才起作用。

因此,如果这不起作用,可以尝试将您的个人资料名称更改为Git Bash或等以外的名称。WSL

  • 不幸的是,它仍然拒绝为我使用命令提示符而不是 powershell。 (2认同)

ARH*_*UMI 5

对我有用的解决方案是:

方法一:

打开Settings.json文件并添加以下代码行

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

进行此更改后,我的Settings.json文件如下所示:

{
    "files.autoSave": "afterDelay",
    "window.zoomLevel": 1,
    "liveServer.settings.donotVerifyTags": true,
    "liveServer.settings.donotShowInfoMsg": true,
    "terminal.integrated.automationShell.windows": "",
    "terminal.integrated.automationShell.linux": "",
    "terminal.integrated.defaultProfile.windows": "Command Prompt"
}
Run Code Online (Sandbox Code Playgroud)

方法二:

点击Settings并搜索defaultprofilewindows

您将在此选项卡上获得默认终端。单击菜单列表并选择Command Prompt

您可以选择任何可用的终端并检查哪一个可以按照您的需要工作。

注意:使用任何一种方法都会得到相同的结果。上述两种方法对我来说都非常有效。