gpt4 book ai didi

visual-studio-code - VSCode : Open new terminal as part of task?

转载 作者:行者123 更新时间:2023-12-01 15:00:18 25 4
gpt4 key购买 nike

Visual Studio Code 刚刚更新为允许运行任务并在拆分终端中打开它们。这很棒,但是我正在寻找另一件事来使其完美。

我希望能够通过任务总共打开 3 个终端。一个用于我的 NPM 构建,一个用于我的后端 MAVEN 构建,第三个只是一个空白的新终端,我可以在需要时用于 git 命令。

我似乎无法找到一种方法来告诉 VSC 运行一个任务,该任务只是打开一个准备使用的新终端而不提供命令。我什至会给它一个简单的命令,比如“node -v”来启动它,只要该面板在之后仍然可用。现在它想在运行后关闭它。

这是我的任务设置:我有一个任务设置作为依赖于另外两个的构建任务。我设想在只打开新终端的情况下添加第三个:

{
"version": "2.0.0",
"tasks": [
{
"label": "Run Maven and NPM",
"dependsOn": [ "maven", "npm" ],
"group": {
"kind": "build",
"isDefault": true,
},
},
{
"label": "maven",
"command": "...",
"type": "shell",
"presentation": {
"reveal": "always",
"group": "build"
},
"options": {
"cwd": "${workspaceRoot}/server"
}
},
{
"label": "npm",
"type": "shell",
"command": "ng serve --port 4203 --proxy-config proxy.conf.json",
"presentation": {
"reveal": "always",
"group": "build"
},
"options": {
"cwd": "${workspaceRoot}/client-APS"
}
}
]
}

最佳答案

以下应该工作:

{
"type": "process",
"label": "terminal",
"command": "/bin/bash", // <-- your shell here
"args": [
"-l" // login shell for bash
],
"problemMatcher": [],
"presentation": {
"echo": false, // silence "Executing task ..."
"focus": true,
"group": "build", // some arbitrary name for the group
"panel": "dedicated"
},
"runOptions": {
"runOn": "folderOpen"
}
}

当我偶然发现这个解决方案时,我试图实现非常相似的东西:在这里,当文件夹在 vscode 中打开时,我自动启动(并设置焦点)终端——以及共享相同的其他任务 presentation.group运行时被放置在拆分终端中(新的与重用的拆分取决于它们的 presentation.panel)

( runOptions 位对于您的情况是多余的,但我保留它以防它对某人有帮助)

注意:对于此示例,您可能需要也可能不需要 -l选项取决于您对 terminal.integrated.shell* 的设置, terminal.integrated.automationShell*terminal.integrated.inheritEnv -- this issue 对设置 shell 环境所涉及的内容进行了一些讨论。

关于visual-studio-code - VSCode : Open new terminal as part of task?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54578615/

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