Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code run code in the same terminal [duplicate]

I didn't find the answer on Internet so I'm asking here. I'm actually dev on Visual Studio Code some language like Python for example. If I'm running the code, it's always opening a new terminal so I can have faster a lot of terminal opened and it's a pain to close them every time. It is possible to run the code in the current terminal opened without write my self "python filename" ?

like image 844
Steve A. Avatar asked Apr 29 '26 04:04

Steve A.


1 Answers

To run a project in VSCode as a task, all you need to do is create a .vscode/tasks.json file like so. The following task will open in the integrated terminal:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Run shell command",
            "type": "shell",
            "command": "echo 'Hello world!'",
            "group": "test",
            "presentation": {
                "panel": "shared", 
                "reveal": "always",
                "focus": true
            },
        }
    ]
}

Key focus to running in the same terminal is the "panel": "shared" line. This runs the command in the same terminal.

Note: this task is untested as I do not have access to a VSCode instance at the moment.

Here is some more information on VSCode tasks. Here is a Python task tutorial by VSCode. More information on task output behaviour.

like image 61
Spencer Pollock Avatar answered May 02 '26 22:05

Spencer Pollock



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!