vscode终端显示分支信息在Windows 和 mac电脑上的配置

第一步:打开 VSCode 的 settings.json

  1. 打开 VSCode,按 Ctrl+,(Windows)/Cmd+,(Mac)打开设置界面;
  2. 点击设置界面右上角的「Open Settings (JSON)」图标(页面右上角的 {} 按钮),打开纯文本的 settings.json 文件。

第二步:分系统粘贴配置

1. Windows 系统(适配 PowerShell 显示 Git 分支)

swift 复制代码
{
  // 核心:指定默认终端为 PowerShell(必选)
  "terminal.integrated.defaultProfile.windows": "PowerShell",
  // 可选:PowerShell 路径(适配不同系统版本,一般无需修改)
  "terminal.integrated.profiles.windows": {
    "PowerShell": {
      "source": "PowerShell",
      "icon": "terminal-powershell",
      "args": ["-NoLogo"] // 关闭启动时的 logo 提示,更简洁
    },
    "Command Prompt": {
      "path": [
        "${env:windir}\\Sysnative\\cmd.exe",
        "${env:windir}\\System32\\cmd.exe"
      ],
      "args": [],
      "icon": "terminal-cmd"
    },
    "Git Bash": {
      "path": "D:\\git的安装路径\\Git\\bin\\bash.exe"
    }
  },
  // 可选:终端外观优化(非必需,按需保留)
  "terminal.integrated.fontFamily": "Consolas, 'Courier New', monospace",
  "terminal.integrated.fontSize": 14,
  "terminal.integrated.cursorStyle": "line"
}

2. Mac 系统(适配 zsh 显示 Git 分支,主流)

ruby 复制代码
{
  // 核心:指定默认终端为 zsh(必选)
  "terminal.integrated.defaultProfile.osx": "zsh",
  // 可选:zsh 路径(Mac 自带 zsh,无需修改)
  "terminal.integrated.profiles.osx": {
    "zsh": {
      "path": "/bin/zsh",
      "icon": "terminal-zsh",
      "args": ["-l"] // 强制加载 ~/.zshrc 配置,确保分支显示生效
    },
    "bash": {
      "path": "/bin/bash", 
      "icon": "terminal-bash"
    },
    "Git Bash": {
      "path": "/bin/bash",
      "icon": "terminal-bash"
    }
  },
  // 可选:终端外观优化(非必需,按需保留)
  "terminal.integrated.fontFamily": "Menlo, Monaco, monospace",
  "terminal.integrated.fontSize": 14,
  "terminal.integrated.cursorStyle": "line"
   // 告诉 VSCode:"不要自己找 Git 了,直接用 `/opt/homebrew/bin/git` 这个路径下的 Git 程序
   "git.path": "/opt/homebrew/bin/git",
}

若 Mac 用 bash,只需将上述配置中 zsh 替换为 bash,路径改为 /bin/bash 即可。


关键提醒

  1. 粘贴配置后保存 settings.json(Ctrl+S/Cmd+S),重启 VSCode 使配置生效;
  2. 若仍不显示分支,先在系统原生终端(Windows 终端 / Mac 终端)验证分支是否显示,排除 shell 配置问题。
相关推荐
ServBay11 天前
Local harness 将退役,VS Code 本地开发要不要搬到云端?
后端·ai编程·visual studio code
DigitalOcean1 个月前
不受限于 Copilot,教你在 VS Code 中接入 GPT、Claude
agent·visual studio code
formulahendry1 个月前
为什么全世界都在 Fork 它?VS Code 官方纪录片(中字完整版)正式上线!
微软·visual studio code·vs code
三十而立洋1 个月前
知枝 · MindSprout:可以直接将 markdown 转换为思维导图的 vscode 插件
前端·visual studio code
formulahendry1 个月前
在 VS Code 里自由切换 Copilot、Claude、Codex、OpenCode、Pi、Kimi、Qwen:任何 Agent 都能接
visual studio code·vs code·acp
开开心心就好1 个月前
打印机卡住打不了?一键清理卡死打印队列
服务器·开发语言·算法·pdf·ocr·idea·visual studio code
free-elcmacom2 个月前
手撕 memcpy 和 memmove:从字节级拷贝到内存重叠的终极较量
c语言·开发语言·青少年编程·visual studio code·visual studio
free-elcmacom2 个月前
发际线警告!手撕《C陷阱与缺陷》终极 BOSS:signal 函数与 typedef 魔法
c语言·开发语言·visual studio code·visual studio
前端小白乘风2 个月前
VS Code 终于能连微信了!发现一个硬核开源神仙插件:WeChat AHP
微信·visual studio code·deepseek
free-elcmacom2 个月前
C语言指针进阶——指针数组模拟二维数组,以及二级指针到底怎么理解
c语言·visual studio code