【问题标题】:Change default terminal app in Visual Studio Code on Mac在 Mac 上的 Visual Studio Code 中更改默认终端应用程序
【发布时间】:2015-07-09 13:10:33
【问题描述】:

我想更改 Visual Studio Code for Mac 使用的默认终端应用程序。我认为这是偏好或设置 json 的一部分,但不确定。

【问题讨论】:

  • 请看答案2

标签: terminal iterm2 visual-studio-code


【解决方案1】:

这些答案都不适合我。这是我为使其工作而进行的更改:

选择默认shell为zsh:

CMD + SHIFT + P 打开命令面板。然后输入Terminal: Select Default Shell。然后您可以选择zsh

更改终端以使用 iTerm

更改字体系列以使用 Powerlevel10k

结果

【讨论】:

  • "terminal.integrated.fontFamily": "Hack Nerd Font" 就像一个魅力。
  • 没有其他工作,但这确实谢谢!
【解决方案2】:

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

  1. 使用View > Command Palette 打开Command Palette (或者干脆Command + Shift + P

  2. 将以下行添加到user settings

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

【讨论】:

  • 这并不能回答问题。这是关于更改使用的终端,而不是外壳。
  • 它仍然很有帮助。谢谢。
  • 不回答@JoséCoelho 指出的问题
【解决方案3】:

对于那些想要更改默认集成终端不仅仅是外部,并添加custom themes,显示您在哪个git branch,以及文件是否需要@987654329 @for example.

按照这些简短步骤:

确保您已安装这些:

iTerm2, oh-my-zsh

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

转到here 并点击download

打开文件

点击install font

(注意:没有这个,vscode集成终端将无法正确渲染主题)

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

cd ~ ;代码.zshrc

iTerm的主题改为agnoster

⌘f.zshrc文件中打开搜索

输入ZSH_THEME

搜索直到找到实时代码,不是注释掉的代码:)

编辑代码使其看起来像ZSH_THEME="agnoster"

保存文件

使用快捷方式打开 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"
}

完成!享受您的新冰封终端

-(可选定制)-

如果您希望提示显示除您的用户名之外的其他内容,例如雷电,例如 mineanything 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"

(注意:从技术上讲,您可以更改有关终端提示的所有内容,但为了保持简短和简单,我们只编辑了用户名部分)

【讨论】:

  • 看起来你也提高了行高给文本一点喘息的空间:"terminal.integrated.lineHeight": 1.5
  • 您能否详细说明:如何添加像您的闪电粗体这样的小图标?
  • 刚刚想通了:prompt_segment black default "%(!.%{%F{yellow}%}.)"$'\u26a1'
  • 终端只支持等宽字体
  • 它工作正常,但我推荐以下字体:"terminal.integrated.fontFamily": "Cousine for Powerline"
【解决方案4】:

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

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

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

  1. 在终端打开

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

【讨论】:

  • 最后,我还需要在设置中添加这一行 "terminal.integrated.shell.osx": "zsh"
  • 这是iTerm2.app使用iTerm2的人吗?
  • @ArupRakshit 不,如果您查看您的应用程序文件夹,即使它是 iTerm2,该应用程序也称为 iTerm.app。
【解决方案5】:

我知道已经很晚了,但是你可以通过运行命令来更改它

Terminal: Select Default Shell

简单多了

【讨论】:

  • 在帖子上挖坟,但上述解决方案对特定用例会有所帮助。
  • 这个答案太棒了。谢谢@kent。
  • 我找不到那个命令 - 我想它现在可能是终端:选择默认配置文件,虽然我不确定,因为我没有让它工作
【解决方案6】:

来自 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

【讨论】:

    【解决方案7】:

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

    【讨论】:

    • 对于任何阅读本文的人来说,正确答案在下面。更改设置"terminal.external.osxExec": "iTerm.app"
    • 您可以将外部终端更改为 iterm2(它会打开一个单独的窗口,而不是在 vscode 内部),但不能将集成 shell 更改为。见:stackoverflow.com/a/44163545/1316649
    猜你喜欢
    • 1970-01-01
    • 2020-08-20
    • 2017-09-04
    • 1970-01-01
    • 2022-01-07
    • 1970-01-01
    • 2021-11-01
    • 2018-05-16
    • 2017-11-26
    相关资源
    最近更新 更多