【问题标题】:Use cmder as default shell in VSCode在 VSCode 中使用 cmder 作为默认 shell
【发布时间】:2021-05-11 21:29:00
【问题描述】:

我能找到的关于这个问题的所有其他解决方案都说将下面的设置放在 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)。阅读更多 关于配置外壳。已弃用,请使用 #terminal.integrated.defaultProfile.windows# 改为(2)

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

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

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

【问题讨论】:

    标签: visual-studio-code cmder


    【解决方案1】:

    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"
    

    【讨论】:

    • 我不明白为什么你们都通过 cmd 中的 init.bat 文件启动???当您下载适用于 Windows 10 的 cmder 时,它会以打包在 zip 文件中的可执行文件(即 shell 程序)的形式出现。你为什么要打开一个shell只是为了运行一个运行另一个shell的命令???感觉有点违反直觉……
    • 我基本上将 OP 想要的相同功能移植到新的设置配置中。这些设置与之前用于 OP 的设置相同
    【解决方案2】:

    cmder 是一个可执行程序。您不需要使用批处理脚本来打开它。只需触发 exe 即可启动程序。

    (来自官方下载页面:)

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

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

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

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

    【讨论】:

      【解决方案3】:

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

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

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

      【讨论】:

      • 这只是启动 Windows 终端。 OP 正在尝试启动第 3 方下载的 shell。
      • 只需将配置值更改为第三方下载的shell路径即可。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-17
      • 2023-02-26
      • 2021-08-08
      相关资源
      最近更新 更多