Every time I started working on a project I had open up two to three different Terminal windows to start development work 🙄.

One to start the Docker, other to start the server and finally one more to run the frontend. And viewing logs on all these terminal one after the other was also getting annoying so I did some research and found something incredible 🚀.

You can create one script and chain different commands using & to run multiple attached sessions as shown below.

# package.json file

{
    ...
    scripts: {
        ...
        "run:dev": "docker-compose up & (cd path/to/server && ./run/server) & yarn start"
    }
}

The benefits of using this is just out of this world. You will be using one terminal window to view logs from multiple different projects.

And to kill the previous processes in the chain use the following syntax. Ctrl + C will only close the later one.

# To list all the running processes. Explore how the name works.
ps aux | grep 

pkill  # For MacOS & Linux

taskkill -f -im mac-server # For Windows