更改 Visual Studio 代码中的默认终端应用 Mac

Change default terminal app in Visual Studio Code on Mac

我想更改 Visual Studio 代码 Mac 使用的默认终端应用程序。我认为这是首选项或设置的一部分 json,但不确定。

没有。但是您可以在这里为这个功能投票:https://visualstudio.uservoice.com/forums/293070-visual-studio-code

这里有一个如何让另一个终端成为 VSCode 的默认终端的例子,在这个例子中我下载了 iTerm2 并将 iTerm2 复制到应用程序。

  1. 代码(菜单)> 首选项 > 用户设置

  1. 编辑 settings.json "terminal.external.osxExec": "iTerm.app""terminal.explorerKind": "external"

  1. 在终端中打开

  1. iTerm 现在是从 VSCode
  2. 启动的默认终端

来自visual studio代码博客:

// 64-bit cmd it available, otherwise 32-bit
"terminal.integrated.shell.windows":"C:\Windows\sysnative\cmd.exe"
// 64-bit PowerShell if available, otherwise 32-bit
"terminal.integrated.shell.windows":"C:\Windows\sysnative\WindowsPowerShell\v1.0\powershell.exe"
// Git Bash
"terminal.integrated.shell.windows": "C:\Program Files\Git\bin\bash.exe"
// Bash on Ubuntu (on Windows)
"terminal.integrated.shell.windows": "C:\Windows\sysnative\bash.exe"

参考:Integrated Terminal

好吧,我知道这么晚了,但你可以通过 运行 命令

更改它
Terminal: Select Default Shell

简单多了

对于那些想要更改 默认集成终端 而不仅仅是外部终端的用户,请添加 custom themes,显示您所在的 git branch,以及文件是否需要 staged or committed for example.

按照这些简短步骤操作:

确保安装了这些:

iTerm2, oh-my-zsh

安装 powerline font (我使用的是 Menlo,这是一种非常漂亮且非常流行的字体)

Go here and click on download

Open the file

Click on install font

(Note: without this, vscode integrated terminal will not render themes correctly)

通过运行此命令打开.zshrc文件:

cd ~ ; code .zshrc

iTerm 的主题更改为 agnoster:

Press ⌘f to open search in the .zshrc file

Type ZSH_THEME

Search until you find the live code, NOT the commented out code :)

Edit the code it so it looks like ZSH_THEME="agnoster"

Save the file

使用快捷方式打开 vscode 设置

⌘,

在 vscode 设置中,您会看到 两个面板 。在 右侧 面板上粘贴此内容:

"terminal.external.osxExec": "iTerm.app",
"terminal.integrated.shell.osx": "/bin/zsh",
"terminal.integrated.fontFamily": "Menlo for Powerline"

假设设置在之前是空的,它应该现在看起来像这样:

{
    "terminal.external.osxExec": "iTerm.app",
    "terminal.integrated.shell.osx": "/bin/zsh",
    "terminal.integrated.fontFamily": "Menlo for Powerline"
}

完成!享受你的新冰镇终端

-(可选定制)-

如果您希望提示显示用户名以外的内容,例如雷电,如 mine or anything you want

运行以下命令打开 agnoster 主题

cd ~/.oh-my-zsh/themes/ ; code agnoster.zsh-theme

打开搜索按:

⌘f

将此粘贴到搜索栏中:

prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@%m"

要更改提示显示的内容,请编辑这部分:

$USER@%m

不要更改这部分:

prompt_segment black default "%(!.%{%F{yellow}%}.)

总之,代码现在应该如下所示:

prompt_segment black default "%(!.%{%F{yellow}%}.) Insert here whatever your heart desires"

(Note: Technically you can change everything about your terminal prompt, but for the sake of keeping this short, and simple we only edited the username part)

我最近将 VSCode 中的终端更改为 ozh,只需 1 步和 1 行。

  1. 使用 View > Command Palette 打开 Command Palette (或简单地 Command + Shift + P

  2. 将以下行添加到 user settings

    "terminal.integrated.shell.osx": "zsh"

None 这些答案完全适合我。这是我为使其正常工作所做的更改:

Select默认shell为zsh:

CMD + SHIFT + P 打开命令面板。然后键入 Terminal: Select Default Shell。然后你可以 select zsh

更改终端以使用 iTerm

更改字体系列以使用 Powerlevel10k

结果