gpt4 book ai didi

batch-file - 在 VsCode 中按键执行 bat 文件

转载 作者:行者123 更新时间:2023-12-04 00:21:58 26 4
gpt4 key购买 nike

我正在为 vulkan 编写着色器,必须将其编译为 spir-v。我有一个非常好的批处理文件,它将使用 GLSlangvalidator 为我构建着色器。我正在尝试使用按键在 VsCode 中运行我的批处理文件,以便我可以检查我的代码是否有错误并构建它。我有以下几点:

    {
"key": "f5",
"label": "build",
"type": "shell",
"command": "workbench.action.terminal.sendSequence",
"args" : {"text": ".\\compile.bat"},
"presentation" : {
"reveal": "always"
}

这几乎有效 - 但我仍然必须专注于内置终端面板并按回车键。当然有一种方法可以执行命令,而不仅仅是输入字符串?
谢谢!

最佳答案

tasks.json 中,创建一个任务来运行 .bat 。像这样的东西:

{
"label": "build",
"type": "shell",
"command": "MY_BAT_FILE.bat",
"presentation": {"echo": true, "reveal": "always", "focus": false, "panel": "shared", "showReuseMessage": false, "clear": true},
"group": {"kind": "build", "isDefault": true},
},

然后,使用 Tasks: Run Build Task 热键(默认为 CtrlShiftB)。
它将运行标有 "isDefault": true 的任务。

如果您需要多个热键,您可以改为在您的 keybindings.json 中添加如下条目:
{"key": "f5", "command": "workbench.action.tasks.runTask", "args": "build"},
// ^~ shortcut ^~~~~ task name

关于batch-file - 在 VsCode 中按键执行 bat 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59844962/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com