skip to Main Content

I have couple of scripts I need to run simultaneously. One of them is a long-run script which is currently running and another script is a new script which is in development mode so I need to run it multiple times but I want to do this using Shift+Enter keys for convenience.

Currently, when I hit Shift+Enter, I get switched to the previous terminal where the long-run script is running and nothing happens after, however I have already created a new terminal window and activated the new environment in which I am developing the new script… The only way I can run that new script in new terminal is writing the command in terminal which is inconvenient and takes more time than just hitting Shift+Enter. Could someone help me with that?

3

Answers


  1. The only way I can run that new script in new terminal is writing the command in terminal which is inconvenient

    Workaround: Take a look at the File: Copy Relative Path of Active File command and see what keybinding it’s bound to. You can use that to copy the relative path and then paste into your terminal.

    One of them is a long-run script which is currently running

    I’d suggest just running that long-running one in its own terminal. You can have multiple VS Code integrated terminals open at a time. See the "+" button.

    another script is a new script which is in developement mode so I need to run it multiple times

    Actually. a lot of shells have history features built in (Ex. Bash’s Readline, PowerShell’s PSReadLine, etc.). You can probably just press the up and down arrow keys to navigate between previously-run commands in your shell, and then press enter to run one again.

    For the record, here’s my answer to the actual question here: I don’t know of any way to get exactly what you’re looking for.

    Login or Signup to reply.
  2. One way, as user mentioned, is to create multiple terminals and run your Python files separately on each terminal by command python filename.py.

    You can also try to use jupyter-notebook or python interactive window.

    You can run the required Python scripts separately in different .ipynb files.

    Login or Signup to reply.
  3. For linux or gitbash terminals, you can also run your long running script as a background process in the shell.

    python3 myscript.py &
    

    More details: how-to-run-linux-commands-in-background

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search