Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open multiple split terminals for each npm script?

I have like 5 npm scripts and each of them need their own terminal because they runned in watch mode and write something in console.

Here is the scripts:

"server-build-dev": "cd ts/backend && npx tsc -w && npm run server-lint",
"server-run-dev": "pm2 flush && pm2 start --only server --env development && pm2 logs",
"server-lint": "cd ts/backend && esw -w --ext .ts",
"client-build-dev": "cd ts/configs && npx webpack --config client.webpack.dev.js"

I prefer split terminals to see everything that is happennig.

What i'm hoping is to run all this scripts with one command. So if i type "npm run all-dev" vscode will open 5 split powersells for we where in each will be runned it's own script.

Is it possible? Or maybe there is another way of handling this?

like image 958
ZiiMakc Avatar asked Mar 20 '26 15:03

ZiiMakc


1 Answers

See my answer here : Create multiple terminals and run commands in VSCode

I just changed to use the "workbench.action.terminal.splitInActiveWorkspace", command instead of creating a new terminal for each command and it works nicely. The demo gif doesn't really capture how quickly and fluidly it works. Starting with no terminals open:

open 4 split terminals


You would not be running an master npm script like npm run all-dev but instead running a task that runs 4 npm scripts in 4 split terminals.

Same caveat as in the linked answer - interact with a terminal sometime after running the command - vscode freezes on me if I try to close the editors without opening one or opening a new one for example. Hopefully that bug will be fixed. Just hit the + button first before you start deleting these split terminals and it never freezes on me.

like image 172
Mark Avatar answered Mar 23 '26 03:03

Mark



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!