您可以根据自己的选择同时打开任意数量的终端,只需单击加号或使用链接中注明的热键,然后单击该拆分终端图标或使用它的热键 (CTL+)。
您当然可以添加自己的键绑定来帮助使用多个终端,例如,将它们添加到您的 keybindings.json 文件中,以便对终端进行额外的键盘导航。
[
{ "key": "ctrl+shift+x", "command": "workbench.action.terminal.kill" },
{ "key": "ctrl+shift+j", "command": "workbench.action.terminal.focusNext" },
{ "key": "ctrl+shift+k", "command": "workbench.action.terminal.focusPrevious" },
]
以及本文作者展示的其他选项。
Mastering VS Code's Terminal
然而,您似乎在说,您想运行脚本并让它自动打开一个新终端并自动拆分屏幕以运行该新终端的段。您可能最接近的方法是使用 VSC 文档和本文中所述的 VSC 任务:
Visual Studio Code Tasks and Split Terminals
{
"label": "Run Server",
"type": "shell",
"command": "${config:python.pythonPath} manage.py runserver --noreload",
"presentation": {
"group": "groupServerStuff"
}
},
同一组的所有任务将作为另一个拆分终端打开
同一终端窗口中的窗格。很不错。
不是单独开始每个任务,有没有办法让任务
“调用”或“生成”其他任务...
{
"label": "Run Server",
"dependsOn": [
"Run TCP Server",
"Run Django Server",
"Tail Log File"
]
},
{
"label": "Run Django Server",
"type": "shell",
"command": "${config:python.pythonPath} manage.py runserver --noreload",
"presentation": {
"group": "groupServerStuff"
}
},
{
"label": "Run TCP Server",
"type": "shell",
"command": "${config:python.pythonPath} scripts/tcp_server.py",
"presentation": {
"group": "groupServerStuff"
}
},
{
"label": "Tail Log File",
"type": "shell",
"command": "tail -f /tmp/logfile.txt",
"presentation": {
"group": "groupServerStuff"
}
},