VSCode的集成终端怎么配置?

VSCode集成终端配置通过修改设置指定默认shell及调整外观行为。Windows下可设”terminal.integrated.defaultProfile.windows”为”Git Bash”或”WSL”;macOS和Linux可通过”terminal.integrated.defaultProfile.osx”或”linux”切换shell,如bash或fish;支持自定义路径。常用配置包括:启用持久会话"terminal.integrated.persistentSessionReviveProcess": true,启动命令参数”shellArgs”,字体大小”fontSize”、行高”lineHeight”、滚动缓冲区”scrollback”。打开终端快捷键为Ctrl + `,支持多实例标签切换。

VSCode的集成终端怎么配置?

VSCode的集成终端配置主要通过修改设置来指定默认使用的 shell(命令行程序),以及调整外观和行为。下面介绍几种常见操作系统的配置方法和常用设置。

Windows 系统下配置终端

在 Windows 上,默认终端可能是 Command Prompt 或 PowerShell,你可以切换为 Git Bash、WSL 或其他你喜欢的 shell。

打开 VSCode 设置(快捷键 Ctrl + ,),搜索 “terminal.integrated.defaultProfile”,然后选择你希望的默认终端。也可以直接编辑 settings.json 文件:

例如,使用 Git Bash:

"terminal.integrated.defaultProfile.windows": "Git Bash"

如果你安装了 WSL,可以设为:

"terminal.integrated.defaultProfile.windows": "WSL"

支持的选项包括:
– “Command Prompt”
– “PowerShell”
– “Git Bash”
– “WSL”
– 自定义路径

macOS 和 Linux 配置终端

macOS 默认使用 zsh,Linux 通常使用 bash,但你也可以更改。

比如你想使用 bash 而不是 zsh:

VSCode的集成终端怎么配置?

冬瓜配音

ai在线配音生成器

VSCode的集成终端怎么配置?66

查看详情 VSCode的集成终端怎么配置?

"terminal.integrated.defaultProfile.linux": "bash", "terminal.integrated.defaultProfile.osx": "bash"

如果想用自定义 shell,比如 fish:

"terminal.integrated.profiles.linux": {     "fish": {         "path": "/usr/bin/fish"     } }, "terminal.integrated.defaultProfile.linux": "fish"

常用配置项说明

除了更换 shell,还可以调整以下行为:

  • 自动恢复终端会话
    "terminal.integrated.persistentSessionReviveProcess": true
  • 启动时自动运行命令
    "terminal.integrated.shellArgs.linux": ["--login"]
  • 字体大小和行高
    "terminal.integrated.fontSize": 14
    "terminal.integrated.lineHeight": 1.2
  • 滚动缓冲区大小(保留更多历史输出):
    "terminal.integrated.scrollback": 5000

如何打开终端和快捷键

打开集成终端:

快捷键 Ctrl + `(反引号)即可呼出或隐藏终端面板。
也可通过菜单栏选择 “Terminal” → “New Terminal”。

多个终端实例可以用标签切换,关闭后默认保留,除非设置了自动清理。

基本上就这些。根据你的系统和偏好调整 profile 和参数,就能让 VSCode 终端更顺手。

linux vscode js git json windows 操作系统 session mac macos win bash json git windows vscode macos linux prompt

上一篇
下一篇