目前在 Windows 安装软件特别喜欢使用 Scoop 进行管理

使用 Scoop 安装 PowerShell Core 最新版

scoop install pwsh

发现在 VSCodeTerminal Shells 列表里面依然看不到新安装的 PowerShell Core

VSCode Terminal Shells

但我又不想使用默认的 PowerShell 或者 cmd 当我的 Shell 这时就可以这样配置:

  1. VSCode 里打开 Command Palette(Ctrl+Shift+P) 选择 Preferences: Open Settings (JSON) 打开用户配置文件 settings.json
  2. 添加如下配置
    {
        "terminal.integrated.shell.windows": "C:/Users/${env:USERNAME}/scoop/apps/pwsh/current/pwsh.exe",
        "terminal.integrated.automationShell.windows": "C:/Users/${env:USERNAME}/scoop/apps/pwsh/current/pwsh.exe"
    }
    
    注:如果用户自定义了 Scoop 的路径($env:SCOOP) 则配置为
    {
        "terminal.integrated.shell.windows": "${env:SCOOP}/apps/pwsh/current/pwsh.exe",
        "terminal.integrated.automationShell.windows": "${env:SCOOP}/apps/pwsh/current/pwsh.exe"
    }
    
  3. 重新运行 VSCode

可以看到我们 VSCode 已经使用了 PowerShell Core 作为默认 Terminal Shells

VSCode Default Terminal Shell

参考文献:

Quick Start · lukesampson/scoop Wiki