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 配置问题。
相关推荐
free-elcmacom7 天前
发际线警告!手撕《C陷阱与缺陷》终极 BOSS:signal 函数与 typedef 魔法
c语言·开发语言·visual studio code·visual studio
前端小白乘风7 天前
VS Code 终于能连微信了!发现一个硬核开源神仙插件:WeChat AHP
微信·visual studio code·deepseek
free-elcmacom9 天前
C语言指针进阶——指针数组模拟二维数组,以及二级指针到底怎么理解
c语言·visual studio code
formulahendry9 天前
微信和 VS Code 强强联合!WeChat AHP 来了
visual studio code·vs code
向北丶11 天前
vscode 导入语句排序和删除未使用的导入
前端·visual studio code
Eric_见嘉15 天前
打开这个 VSC 设置「组件引用位置」和数量就都清楚了
前端·typescript·visual studio code
Flynt22 天前
Chrome 修了个零日漏洞,你的 VS Code 和 Cursor 可能还在裸奔
安全·electron·visual studio code
一直C1 个月前
Linux系统编程|进程间通信IPC全套详解(1)(管道、信号)
linux·c语言·开发语言·网络·青少年编程·visual studio code
三十而立洋1 个月前
VSCode插件从0到1开发与发布完整实战
visual studio code
一直C1 个月前
【Linux应用编程】深入理解Linux多任务机制:进程原理、状态转换与进程控制实战
linux·开发语言·算法·ubuntu·vim·visual studio code