You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VSCode中运行task任务后如何获取可交互的终端?

VSCode Task交互式终端配置方案

该需求可以直接实现,只需在原有task配置基础上补充交互相关的参数即可,完整配置如下:

{
    "label": "dune utop",
    "type": "shell",
    "command": "dune_utop.cmd",
    "presentation": {
        "reveal": "always",
        "focus": true,
        "panel": "shared"
    },
    "problemMatcher": []
}

配置项说明

  • type指定为shell:让VSCode通过系统shell调用cmd脚本,原生继承终端交互能力
  • presentation.focus设为true:task启动后会自动将输入焦点切换到对应的终端面板,无需手动点击即可直接输入指令
  • presentation.panel设为shared:多次运行该task会复用同一个终端面板,避免重复生成新窗口
  • 不要配置isBackground: true:后台运行模式会抢占终端输入权限,导致交互失效

使用方法

配置保存后,按下快捷键Ctrl+Shift+B(Windows/Linux)或Command+Shift+B(Mac),选择名为dune utop的task启动,待cmd脚本运行完成后即可直接在终端中输入交互指令。

如果你的dune_utop.cmd不在VSCode当前工作区根目录,可以额外添加"cwd": "cmd文件所在的目录绝对路径"配置项,指定脚本运行的工作目录。


内容的提问来源于stack exchange,提问作者Butanium

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.24 05:45:03