如何禁用默认情况下由VS Code定义的集成终端配置文件?

huangapple go评论55阅读模式
英文:

How can I disable integrated terminal profiles that VS Code defines by default?

问题

以下是您要的翻译部分:

"When I click on new terminal I see all the shells available in my Windows 11 (powershell, ubuntu from WSL, gitbash, etc)"

当我点击新终端时,我看到我在Windows 11中可用的所有Shell(powershell、来自WSL的ubuntu、gitbash等)。

"What I need is a configuration to remove / hide / disable the ones I don't use and only leave 1 or 2, that is, from the list, only keep Powershell and Ubuntu, instead of the 5 that appear."

我需要的是一种配置,以删除/隐藏/禁用我不使用的那些,并只保留1或2个,也就是说,只保留Powershell和Ubuntu,而不是显示的5个。

"The only settings asociate to terminal I have is:"

我唯一拥有的与终端相关的设置是:

"terminal.integrated.profiles.windows": {
    "pwsh": {
      "path": "C:\\Program Files\\PowerShell\\\pwsh.exe",
      "args": ["-nologo"]
    }
  },

以下是默认显示在Windows上的配置文件:

以下是默认显示在Windows上的配置文件:

如何禁用默认情况下由VS Code定义的集成终端配置文件?

I need is a configuration to remove the ones I don't use.

我需要的是一种配置,以删除我不使用的那些。

I have been looking for information about this topic but I have not found how to achieve it.

我一直在寻找关于这个主题的信息,但我没有找到如何实现它。

UPDATE:

更新:

"terminal.integrated.profiles.windows": {
    "PowerShell": null,
    "Git Bash": null,
    "Command Prompt": null,
    "Ubuntu-20.04 (WSL)": null,
    "JavaScript Debug Terminal": null,
    "Windows PowerShell": null,

    "pwsh": {
      "path": "pwsh.exe",
      "args": ["-nologo"],
      "name": "pwsh"
    },
    "bash": {
      "path": ["C:\\WINDOWS\\System32\\bash.exe"],
      "name": "bash"
    }
  },
  "terminal.integrated.defaultProfile.windows": "bash",

Hope this helps! 希望这有所帮助!

英文:

When I click on new terminal I see all the shells available in my Windows 11 (powershell, ubuntu from WSL, gitbash, etc)

What I need is a configuration to remove / hide / disable the ones I don't use and only leave 1 or 2, that is, from the list, only keep Powershell and Ubuntu, instead of the 5 that appear.

The only settings asociate to terminal I have is:

"terminal.integrated.profiles.windows": {
    "pwsh": {
      "path": "C:\\Program Files\\PowerShell\\\pwsh.exe",
      "args": ["-nologo"]
    }
  },

Here are the profiles that show up by default on Windows:

如何禁用默认情况下由VS Code定义的集成终端配置文件?

I need is a configuration to remove the ones I don't use.

I have been looking for information about this topic but I have not found how to achieve it.

UPDATE:

I solved with this:

"terminal.integrated.profiles.windows": {
    "PowerShell": null,
    "Git Bash": null,
    "Command Prompt": null,
    "Ubuntu-20.04 (WSL)": null,
    "JavaScript Debug Terminal": null,
    "Windows PowerShell": null,

    "pwsh": {
      "path": "pwsh.exe",
      "args": ["-nologo"],
      "name": "pwsh"
    },
    "bash": {
      "path": ["C:\\WINDOWS\\System32\\bash.exe"],
      "name": "bash"
    }
  },
  "terminal.integrated.defaultProfile.windows": "bash",

答案1

得分: 0

似乎 VS Code 总是将默认定义的终端配置文件合并到最终的配置文件列表中,而您无法阻止它这样做。

您可以重新定义它们为 null,或将这些字段设置为空。

对于默认配置文件,如果使用 "path" 字段,它不会显示一个带有 "path" 设置为空数组或指向不存在的路径的配置文件选项。

对于支持并使用 "source" 字段而不是 "path" 字段的默认配置文件,将 "source" 字段设置为 null

您可以在默认设置 JSON 文件中找到默认终端配置文件的列表(使用 Preferences: Open Default Settings (JSON),然后使用编辑器的搜索功能搜索 terminal.integrated.profiles.)。然后,只需将其复制并粘贴到您的用户或工作区 settings.json 文件中,并按照上述说明调整值。

以下是我自己 Windows 机器的示例:

"terminal.integrated.profiles.windows": {
    "PowerShell": {
        "source": null
    },
    "Command Prompt": {
        "path": [],
        "icon": "terminal-cmd"
    },
    "Git Bash": {
        "source": null
    },
    "Ubuntu-20.04 (WSL)": {
        "path": []
    },
}

另一种方法是这样:

"terminal.integrated.profiles.windows": {
    "PowerShell": null,
    "Command Prompt": null,
    "Git Bash": null,
    "Ubuntu-20.04 (WSL)": null,
    "JavaScript Debug Terminal": null,
}
英文:

It seems that VS Code will always merge in the default-defined terminal profiles to the final list of profile definitions and that you can't stop it from doing that.

What you can do is just redefine them either to null, or set those fields to nothing.

For default profiles that use the "path" field, it will not show a profile option with "path" set to an empty array, or a path to something that doesn't exist.

For default profiles that support and use the "source" field instead of the "path" field, set the "source" field to null.

You can find the list of default terminal profile definitions in the default settings JSON file (use the Preferences: Open Default Settings (JSON), and then use the editor search feature to search terminal.integrated.profiles.). Then just copy and paste it into your user or workspace settings.json file and adjust the values as described above.

Here's an example for my own Windows machine:

"terminal.integrated.profiles.windows": {
    "PowerShell": {
        "source": null
    },
    "Command Prompt": {
        "path": [],
        "icon": "terminal-cmd"
    },
    "Git Bash": {
        "source": null
    },
    "Ubuntu-20.04 (WSL)": {
        "path": []
    },
}

The other way to do it is this:

"terminal.integrated.profiles.windows": {
    "PowerShell": null,
    "Command Prompt": null,
    "Git Bash": null,
    "Ubuntu-20.04 (WSL)": null,
    "JavaScript Debug Terminal": null,
}

huangapple
  • 本文由 发表于 2023年2月16日 04:39:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/75465221.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定