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 配置问题。
相关推荐
一直C7 天前
Linux系统编程|进程间通信IPC全套详解(1)(管道、信号)
linux·c语言·开发语言·网络·青少年编程·visual studio code
三十而立洋10 天前
VSCode插件从0到1开发与发布完整实战
visual studio code
一直C11 天前
【Linux应用编程】深入理解Linux多任务机制:进程原理、状态转换与进程控制实战
linux·开发语言·算法·ubuntu·vim·visual studio code
我一定会有钱19 天前
打造完美工作流:Git 配置”一次推送,三端同步”(Gitee/GitCode/GitHub)
开发语言·windows·vscode·搜索引擎·gitlab·github·visual studio code
初辰ge23 天前
从 Cursor 切换 Claude Code,最劝退的「@ 选上下文」痛点,我用一个插件解决了
visual studio code
晴殇i1 个月前
🚀 Remote Deploy Helper|VSCode 部署助手
visual studio code
慢功夫1 个月前
💡第七篇:VSCode语言服务中,代码跳转和诊断是怎么做的?
前端·visual studio code
yiyesushu1 个月前
GitHub Copilot 在 vscode 中使用之 Prompt
人工智能·visual studio code
程序员Supers2 个月前
VSCode 好用插件推荐
visual studio code
慢功夫2 个月前
💡第五篇:VSCode插件是如何与主进程通信的?
前端·visual studio code