在 VSCode 中使用 cmder 作为默认 shell

问题描述

我能找到的所有其他解决方案都说将下面的设置放在 my.vscode/settings.json 中

"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe","terminal.integrated.shellArgs.windows": [
     "/K","C:\\softwares\\cmder\\vendor\\init.bat"
],

直到最近,当我从 git 存储库中删除我的设置文件时,这才有效。现在,当我将鼠标悬停在上面的代码上时,我会在弹出窗口中看到此文本

终端在 Windows 上使用的 shell 的路径(认: C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe)。阅读更多 关于配置shell。已弃用,请使用 #terminal.integrated.defaultProfile.windows# 代替(2)

这让我有点困惑,我不确定我必须改变什么。我尝试将第一个设置更改为

"terminal.integrated.defaultProfile.windows": "C:\\WINDOWS\\System32\\cmd.exe",

但这没有任何效果。 Cmder 未被用作认 shell。

解决方法

https://github.com/transferwise/sequence-layout 是一个可执行程序。您不需要使用批处理脚本来打开它。只需启动 exe 即可启动程序。

(来自官方下载页面:)

  1. 解压
  2. (可选)将自己的可执行文件放入要注入的bin文件夹中 你的路径。
  3. 运行 Cmder (Cmder.exe)

因此,您只需要在 settings.json 中添加一行:

"terminal.integrated.shell.windows": "C:\\full\\path\\to\\unzipped\\cmder.exe"

这不需要接受任何标志或命令,args,除非您想更改它的默认功能(例如更改光标在启动时指向的默认文件夹)。对于默认的cmder,只需运行exe...

,

VSCode 更改了在 April 2021 中处理集成终端配置文件的方式。根据您在问题中提供的参数,将此添加到您的 settings.json 应该可以:

    "terminal.integrated.profiles.windows": {

        "PowerShell": {
            "source": "PowerShell","icon": "terminal-powershell"
        },"Command Prompt": {
            "path": [
                "${env:windir}\\Sysnative\\cmd.exe","${env:windir}\\System32\\cmd.exe"
            ],"args": [
                "/K","C:\\softwares\\cmder\\vendor\\init.bat"
            ],"icon": "terminal-cmd"
        }
    },"terminal.integrated.defaultProfile.windows": "Command Prompt"
,

尝试在 settings.json 中添加跟随配置

"terminal.integrated.automationShell.windows": "C:\\WINDOWS\\System32\\cmd.exe",

设置后将覆盖 terminal.integrated.shell.windows 并忽略 shellArgs 值的路径,用于与自动化相关的终端使用(如任务和调试)。