终端相关配置
修改默认的终端
参考(2024-12验证可用):ZSH And VSCode - Default Shells
- Open Command Palette: Windows - Ctrl + Shift + P; Mac - ⌘ + Shift + P
- Search For
Terminal: Select Default Shell
and select it. - See the list of available shells and select one. If you cannot see zsh here, then you might have some configuration issues with zsh.
It also likely that the zsh installation/configuration error caused your entry in settings.json file to be invalid. Once you have selected the shell, hit ctrl + ~ or ⌘ + J to open the terminal window and see the results. If you already opened a terminal then you would have to trash it or open another one.
You could also open your settings.json and see or add the following entry directly.
// Edit July 2021 - New Updated Snippet
"terminal.integrated.defaultProfile.osx": "zsh"
// Now deprecated
"terminal.integrated.shell.osx": "/bin/zsh"
在Visual Studio Code中设置默认终端,请按照以下步骤操作:
- 打开Visual Studio Code。
- 点击左上角的"文件"(File)菜单,然后选择"首选项"(Preferences)> "设置"(Settings)。或者,您可以按快捷键
Ctrl + ,
(Windows/Linux)或Cmd + ,
(Mac)直接打开设置。 - 在设置页面的搜索框中输入
terminal
,找到与终端相关的设置项。 - 在搜索结果中找到
"terminal.integrated.defaultProfile"
设置项。点击下拉菜单,然后从列表中选择您希望设置为默认的终端。例如,如果您希望将PowerShell设置为默认终端,请选择"PowerShell"
。 - 如果您还没有安装所需的终端,可以在设置中找到相关扩展并安装。例如,要安装PowerShell扩展,请转到扩展视图(点击左侧边栏中的扩展图标或按
Ctrl + Shift + X
),然后在搜索框中输入PowerShell
,找到并安装它。 - 完成设置后,重启Visual Studio Code。现在,当您打开新的终端时,系统将使用您选择的默认终端。
注意:在macOS上,您还可以通过安装第三方终端(如iTerm2)并在设置中配置"terminal.integrated.defaultProfile"
来设置默认终端。但是,请注意,这可能需要额外的配置,因为iTerm2不是Visual Studio Code内置支持的终端。
设置选择时自动复制
在VSCode中,您可以通过设置终端的terminal.integrated.copyOnSelection
选项来实现自动拷贝所选内容。请按照以下步骤操作:
- 打开VSCode。
- 点击左上角的菜单栏中的"文件"(File)> "首选项"(Preferences)> "设置"(Settings)。
- 在设置页面的搜索框中输入
terminal.integrated.copyOnSelection
。 - 在搜索结果中找到
Terminal > Integrated: Copy On Selection
选项。 - 勾选该选项以启用自动拷贝所选内容。
现在,当您在VSCode终端中选择文本时,所选内容将自动复制到剪贴板。