在Mac上的Visual Studio代码中更改默认终端应用程序

问题描述 投票:33回答:6

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

terminal iterm2 visual-studio-code
6个回答
-11
投票

不,但你可以在这里投票支持这个功能:https://visualstudio.uservoice.com/forums/293070-visual-studio-code


87
投票

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

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

enter image description here

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

enter image description here

  1. 在终端开放

enter image description here

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

enter image description here


45
投票

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

Follow these short steps:

确保安装了以下内容:

iTerm2oh-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"

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


4
投票

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

  1. 使用Command Palette(或简称View > Command Palette)打开Command + Shift + P
  2. 将以下行添加到user settings"terminal.integrated.shell.osx": "zsh"

enter image description here


3
投票

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


1
投票

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

Terminal: Select Default Shell

它更容易

© www.soinside.com 2019 - 2024. All rights reserved.