I am running Ubuntu 21.04 and I want to create a script, that would do the following:
Run:
cd && cd path/to/repo && git pull && npm i && code . && npm run dev
Then open a new GNOME Terminal tab using:
gnome-terminal --tab
Then switch to this tab and run:
cd && cd path/to/repo && git reset --hard && git pull -f && npm i && npm run dev
So basically I want one terminal with 2 tabs running 2 development servers.
I tried with xdotool
and xte
, but it never worked (keys aren't even pressed).
Is it even possible to do what I want?
As suggested below I tried, it gave me failed to run cd
so I googled and came up with the following:
gnome-terminal --tab -- /bin/bash -e -c "cd path/to/repo && ls && git pull && npm i && code . && npm run dev" --tab -- /bin/bash -e -c "cd path/to/repo && git reset --hard && git pull -f && npm i && npm run dev"
But the problem is that npm run dev
is not supposed to ever stop, and so the second terminal tab is not ever opened.
And I need to run them together...
gnome-terminal
may not anymore be possible, because any commands need to come at the end nowadays after--
. You may need another terminal emulator to be able to automatically set up two tabbed sessions.cd && cd path/to/repo
. Either thepath/to/repo
is a full path so you just docd path/to/repo
or, if it is relative to your$HOME
, you can docd ~/path/to/repo
.cd && cd path/to/repo
, I am currently copying and pasting the command, so it's sort of my way ofgit pull && npm i && npm run dev
, regardless the current directory.