Home > Back-end >  How do I have VS Code run a bash script (or other script) when it opens?
How do I have VS Code run a bash script (or other script) when it opens?

Time:12-22

I do most of my development via VS Code on my local machine. Whenever I open the editor I manually run a bash script (in the integrated terminal) that does the following things:

  1. Starts a local instances of several webapp with hot-reload enabled
  2. Starts the Dagster UI via Dagit
  3. Starts the ML Flow UI
  4. Starts a Tensorboard server etc...

I sometimes forget to run the bash script, which causes the occasional frustration when I have to re-run things or interrupt my work for this.

The most expedient way to fix it that comes to mind is to set things up so the .sh script runs whenever VS Code is opened.

Any ideas if this is possible? Maybe via an extension?

CodePudding user response:

VS Code have tasks support, like Grunt/Gulp/etc, which include running arbitrary shell scripts. You can run pretty much anything you want and you can find out more in the official documentation

CodePudding user response:

No extension needed, try to adapt following .vscode/tasks.json

{
    "version": "2.0.0", 
    "presentation": { "echo": false },
    "tasks": [
        { "label": "First", "type": "shell", "command": "echo Run whatever scripts needed here; exec bash", "runOptions": { "runOn": "folderOpen" } }
    ]   
}
  • Related