Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to split the terminal when running tasks in VSCode?

In Visual Studio Code you can now split the integrated terminal in half. I am using VSCode's tasks feature as well to run two tasks always at the same time. How can I make it so when I run a task it will automatically split the current terminal, using the new one for the task?

Basically I'm wanting to open VSCode, it should auto open the integrated terminal like normal, and then I can run my two tasks which should end me with a terminal split into three like so:

------------------------------------------------------
| default terminal   | Task 1       | Task 2         |
------------------------------------------------------

EDIT (SOLVED): VSCode has been updated to allow this now :D https://code.visualstudio.com/updates/v1_31#_task-output-support-split-terminals

You can now configure tasks to show output in a split terminal panel instead of creating a new one. A task configuration can use the group attribute in the presentation section to define where the task's output should be shown.

like image 641
BlueCaret Avatar asked Sep 19 '18 16:09

BlueCaret


People also ask

How do I open two terminals in VS Code?

Open commands search (use Ctrl+Shift+P or from menu View->Command Palette...) In command box Type "Terminal: Select Default Shell" to select this option from drop down. Just click any one which you like to add for quick access from command list.


1 Answers

When creating your task make sure to have the presentation.reveal option set to always and presentation.panel option set to new. That way the output is always revealed and a new terminal is created on every task run

Example:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Run tests",
            "type": "shell",
            "command": "./scripts/test.sh",
            "windows": {
                "command": ".\\scripts\\test.cmd"
            },
            "group": "test",
            "presentation": {
                "reveal": "always",
                "panel": "new"
            }
        }
    ]
}

More info at: Tasks in Visual Studio Code

EDIT: Since you want new tasks into split terminals, maybe this info helps. I don't think it is possible to do it: Launch task directly into split terminal

like image 55
Luan Moraes Avatar answered Oct 02 '22 06:10

Luan Moraes