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.jsonCtrl+S/Cmd+S),重启 VSCode 使配置生效;
  2. 若仍不显示分支,先在系统原生终端(Windows 终端 / Mac 终端)验证分支是否显示,排除 shell 配置问题。
相关推荐
天朝八阿哥1 天前
使用Docker+vscode搭建离线的go开发调试环境
后端·docker·visual studio code
敲敲敲敲暴你脑袋4 天前
写个添加注释的vscode插件
javascript·typescript·visual studio code
golang学习记4 天前
GitLens 十大神技:彻底改变你在 VS Code 中的 Git 工作流
前端·后端·visual studio code
小兵张健6 天前
为什么我放弃了 JetBrains 系列,转向 VSCode 等衍生物
visual studio code·jetbrains
晚风予星6 天前
Ant Design Token Lens 迎来了全面升级!支持在 .tsx 或 .ts 文件中直接使用 Design Token
前端·react.js·visual studio code
埃博拉酱7 天前
VS Code Remote SSH 连接 Windows 服务器卡在"下载 VS Code 服务器":prcdn DNS 解析失败的诊断与 BITS 断点续传
windows·ssh·visual studio code
孟陬7 天前
Tanstack Start 的天才创新之处——基于实际使用体验
react.js·visual studio code·next.js
一只叁木Meow8 天前
一个路径,搞崩 VSCode 的 Claude Code 插件
visual studio code
老师用之于民8 天前
【DAY25】线程与进程通信:共享内存、同步机制及实现方案
linux·c语言·ubuntu·visual studio code