如何在 VS Code 2021 年 4 月正确集成 Cmder?

问题描述

我想将 Cmder 集成到我的 Vscode 设置中,但在 2021 年 4 月的 vscode 上更新了命令“terminal.integrated.shell.windows”和“terminal.integrated.shellArgs.windows”已弃用。

我在 Windows 上使用 VS Code 64 位,我尝试修改我的 settings.json 文件,以创建 Cmder 配置文件作为集成终端,如下所示:

  "terminal.integrated.profiles.windows": {
    "Cmder": {
      "source": "Cmder","overrideName": true,"icon": "cmder","env": {"CMDER_ROOT": "C:\\tools\\cmder"},"path": "%CMDER_ROOT%\\Cmder.exe","args": ["/K","%CMDER_ROOT%\\vendor\\bin\\vscode_init.cmd"],},"terminal.integrated.defaultProfile.windows": "Cmder",

但是,集成的“Cmder”配置文件不起作用,并且命令 terminal.integrated.defaultProfile.windows": "Cmder", 显示“此设置只能应用于应用程序用户设置”。

还有其他人试图将 Cmder 集成为 vscode 终端的集成配置文件吗?

解决方法

  1. 打开用户设置(文件 -> 首选项 -> 设置)。
  2. 输入 terminal.integrated.defaultProfiles.windows 并点击 Edit in settings.json
  3. 在终端中定义新配置文件并将 Cmder 设置为默认配置文件:
    "terminal.integrated.profiles.windows": {
        "PowerShell": {
            "source": "PowerShell","icon": "terminal-powershell"
        },"Command Prompt": {
            "path": [
                "${env:windir}\\Sysnative\\cmd.exe","${env:windir}\\System32\\cmd.exe"
            ],"args": [],"icon": "terminal-cmd"
        },"Git Bash": {
            "source": "Git Bash",},"Windows PowerShell": {
            "path": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
        },"Cmder": {
            "path": [
                "${env:windir}\\Sysnative\\cmd.exe","env": {"CMDER_ROOT": "C:\\tools\\cmder"},"args": [
                "/K","%CMDER_ROOT%\\vendor\\bin\\vscode_init.cmd"
            ],"icon": "cmder",}
    },"terminal.integrated.defaultProfile.windows": "Cmder",
  1. 打开一个新终端(终端 -> 新终端)

确保您的 Cmder 目录存在于 C:\tools

享受。

,

以管理员身份打开 PowerShell(右键单击 启动时 --> Windows PowerShell(管理员))

get-executionpolicy -list

set-executionpolicy 不受限制

set.executionpolicy unrestricted -force(如果上面的命令出错)

,

我尝试了您的设置和任何结果。微软弃用了旧的终端设置,现在有任何好的解决方案可以用 cmder 或其他命令行程序打开 :(

,

这对我来说适用于新的 VS Code settings.json 结构并使用 Laragon 的 Cmder 安装。

    "cmder": {
        "path": "C:\\Laragon\\bin\\cmder\\cmder.bat","args": ["."],}