Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way of running VSCode tasks in the *current* integrated terminal?

By default running tasks inside Visual Studio Code opens a new integrated terminal over the current one, which then asks you to press a key to close it. I would really prefer if the current terminal was used instead, as it gets annoying when many new terminals stack over one another after running several tasks. Is there any way of configuring that? I find it hard to believe no one else dislikes the default behavior but can't seem to find anything online or in the settings.

like image 491
yawn Avatar asked Sep 07 '25 22:09

yawn


2 Answers

The way I found to have the command copy-pasted on the current terminal is using keybindings.json command with "workbench.action.terminal.sendSequence" instead of tasks.json. As the following example:

{
    "key": "<your hotkey here>",
    "command": "workbench.action.terminal.sendSequence",
    "args": {
        "text": "<your command here> \n"
    }
}

The \n at the end will make it actually send the command. Otherwise it will just paste and you will have the press enter.

like image 96
user3663027 Avatar answered Sep 10 '25 21:09

user3663027


If I understood your question correctly I think it should be enough if you set panel: "shared" in the presentation field of the task json. This will prevent multiple terminals from stacking and they should all try to use the same one.

Source: https://code.visualstudio.com/docs/editor/tasks#_output-behavior

like image 22
Bernat Felip Avatar answered Sep 10 '25 21:09

Bernat Felip