下面直接给你一套2026 最新、可复制即用的 VSCode Shell 环境配置Windows /macOS/ Linux 都覆盖包括默认 Shell 切换、自定义 profiles、环境变量、登录 / 交互模式、常见坑。一、打开 settings.json必须快捷键WindowsCtrl ,→ 右上角{ }图标macOSCmd ,→ 右上角{ }或命令面板CtrlShiftP → Preferences: Open Settings (JSON)二、Windows 配置Git Bash / PowerShell / WSL1推荐Git Bash 作为默认json{ // 定义 profiles terminal.integrated.profiles.windows: { Git Bash: { path: D:\\Program Files\\Git\\bin\\bash.exe, // 改成你的 Git 安装路径 args: [--login, -i], // 登录模式 交互模式加载 ~/.bashrc icon: terminal-bash }, PowerShell: { source: PowerShell, args: [-NoLogo] }, WSL: { path: wsl.exe, args: [-d, Ubuntu] // 你的发行版 } }, // 设置默认 terminal.integrated.defaultProfile.windows: Git Bash, // 全局环境变量可选 terminal.integrated.env.windows: { PATH: ${env:PATH};${workspaceFolder}/node_modules/.bin, NODE_ENV: development } }path要真实存在常见C:\Program Files\Git\bin\bash.exe--login加载~/.bash_profile-i交互模式加载~/.bashrc解决 conda/nvm 不生效2旧版写法已废弃不要用json// ❶ 老版本2020 前已失效 terminal.integrated.shell.windows: C:\\Git\\bin\\bash.exe三、macOS / Linux 配置zsh /bash1zsh推荐加载 .zshrcjson{ terminal.integrated.profiles.osx: { zsh: { path: /bin/zsh, args: [-l, -i] // 登录交互 }, bash: { path: /bin/bash, args: [-l] } }, terminal.integrated.defaultProfile.osx: zsh, terminal.integrated.env.osx: { PATH: ${env:PATH}:${HOME}/.local/bin } }-l登录 shell → 读.zprofile/.bash_profile-i交互 → 读.zshrc/.bashrc关键2Linux 把osx换成linux即可。四、快速切换默认 Shell不用写 JSON1.打开终端 → 右上角▼→Select Default Profile打开终端 → 右上角 ▼ → 选择默认配置文件2.选Git Bash / PowerShell /zsh/ WSL…3.关闭所有终端 → 重开才生效五、常见问题 解决1~/.bashrc/ ~/.zshrc 不生效原因VSCode 默认非登录、非交互 shell不加载 rc 文件解决在args加-l -i如上配置2Git Bash 中文乱码jsonterminal.integrated.profiles.windows: { Git Bash: { path: D:\\Program Files\\Git\\bin\\bash.exe, args: [--login, -i], env: { LANG: zh_CN.UTF-8, LC_ALL: zh_CN.UTF-8 } } }3终端启动失败 / 路径错误检查path 是否绝对路径 存在Windows 路径用\或/不要混用windows/osx/linux字段六、验证是否生效新终端里执行bash运行# macOS/Linux echo $SHELL cat ~/.zshrc # 看是否加载 # Windows Git Bash echo $0