The reason your double alias command (ib && is
) does not work is because, as per man bash
:
Aliases allow a string to be substituted for a word when it is used as
the first word of a simple command.
Stands to reason that if you run ib && is
where both ib
and is
are aliases, it will only run ib
.
With that out of the way, there is have a different and, I believe, better solution to your problem. You can use screen
to run those 2 commands in the background and also, as a bonus, have the ability to watch their terminal output any time you want.
The idea is this: 1. Start a screen
session; 2. Open two windows inside that session; 3. Run npm run start:backend
in 1st window and run npm run start:dev
in the second window.
Here is what you need:
screen -S Servers -t backend_window -A -d -m
screen -S Servers -X screen -t dev_window
This will start a screen
session with backend_window
and dev_window
inside it. Now you just need to run your 2 commands inside those windows:
screen -S Servers -p backend_window -X stuff $'npm run start:backend
'
screen -S Servers -p dev_window -X stuff $'npm run start:dev
'
Now both your npm commands are running in the background at the same time. You can just put these 4 lines into your .bashrc
file and it will launch on log in.
But the best part about this approach is you can visually see what's going on with those npm commands by attaching the screen and looking inside those windows. Just run:
screen -rx Servers
This will show you your first window by default. Let's split the screen and show both windows side by side:
Ctr-A + | <- will split the screen into 2 sections
Ctr-A + Tab <- will shit cursor to the new section
Ctr-A + " <- will show you your 2 windows, just pick the dev
All this will give you this view
Keep in mind that both your npm commands will continue to run even after you log out. To kill them, either attach the screen as described above and then Ctrl-C both processes. Or just run killall screen
and they will just die.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…