在VSCode中配置默认​​shell和参数命令的新方法?

几天前,我假设微软发布了 VSCode 的新更新,当我开始构建我的 esp idf 项目时它不起作用,因为它依赖于在执行“特殊”项目构建命令之前从终端运行的命令,我得出的结论是,允许自动出现在“设置”中的文件 main.code.workspace 中的以下设置是:

    "terminal.integrated.shell.windows": "cmd.exe",
    "terminal.integrated.shellArgs.windows": [

        "/k", 
        "C:/Coding/ESP32/esp-idf/export.bat"
    ],

错误如下:

这已被弃用,配置默认 shell 的新推荐方法是在 中创建终端配置文件#terminal.integrated.profiles.osx#并将其配置文件名称设置为#terminal.integrated.defaultProfile.osx#. 目前这将优先于新的配置文件设置,但将来会发生变化。

在启动时配置默认终端并运行此命令的新方法是什么?

回答

在 settings.json 文件中,我们需要有以下内容

"terminal.integrated.profiles.windows": {
    "PowerShell": {
        "source": "PowerShell",
        "icon": "terminal-powershell"
    },
    "Command Prompt": {
        "path": [
            "${env:windir}Sysnativecmd.exe",
            "${env:windir}System32cmd.exe"
        ],
        "args": [],
        "icon": "terminal-cmd"
    },
    "Git Bash": {
        "source": "Git Bash"
    }
},

并通过添加设置默认终端

"terminal.integrated.defaultProfile.windows": "Command Prompt",

我们可以通过按 Ctrl + Shift + P 并搜索终端来实现这一点:选择默认配置文件并选择所需的外壳。

但是,尽管已弃用,但您目前拥有的设置现在应该可以使用。

  • Thanks I've added this code block to my main.code-workspace file so it executes every time I load the workspace but how do you make it auto type these two commands at startup?: "/k",
    "C:/Coding/ESP32/esp-idf/export.bat"
  • I believe you can add it in the args field like in this [comment](https://github.com/microsoft/vscode/issues/122355#issuecomment-833086902) so that it executes everytime.

以上是在VSCode中配置默认​​shell和参数命令的新方法?的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>