Search code examples
batch-fileconemu

Run two commands synchronously in a split terminal


I would like to launch my development server using a single launch script in a split console with ConEmu. It can be a ConEmu task, a batch script, or whatever it takes. I have achieved this with Gulp but find that solution to be overkill.

I need to execute

cd C:\Repo\myApp\frontEnd
npm start 

I would then like to split the window cmd -new_console:s50H

And without waiting for npm start to finish, because it does not, execute the following in the new window. Syncronously so to speak.

cd C:\Repo\myApp\backEnd -new_console:s50H
node backEnd.js

Solution

  • Do you really care about executing npm start before creating new split with backend?

    If you don't - the simplest way is starting backend before frontend. Actually, due to some minor delays in processing, your npm start may start same time or even before than node.

    cd /d C:\Repo\myApp\frontEnd
    node backEnd.js -new_console:s50H -new_console:d:"C:\Repo\myApp\backEnd"
    npm start 
    

    Another option is starting npm in background and node thereafter.

    cd /d C:\Repo\myApp\frontEnd
    ConEmuC -async -c npm start 
    node backEnd.js -new_console:s50H -new_console:d:"C:\Repo\myApp\backEnd"