0

I have bash scripts, which I execute from new terminal every time I want to start my project

celery.sh

activate () {
     . /Users/oleg/Desktop/auth/venv/bin/activate
}
activate
cd projectname
celery -A projectname worker -l info

flower.sh

activate () {
     . /Users/oleg/Desktop/auth/venv/bin/activate
}
activate
cd projectname
celery -A projectname flower --port=5555

start.sh

activate () {
     . /Users/oleg/Desktop/auth/venv/bin/activate
}
activate
cd projectname
python manage.py runserver 0.0.0.0:8000

this scripts are used on my local machine, and i execute them with 3 different commands each command in new terminal

./celery.sh

./flower.sh

./start.sh

I found it boring, and redundant that i'm forced to open this 3 terminals each time.

My goal is to create one script ./ultimatestart.sh which will start all of this three scripts, each of which should be opened in its personal terminal

Answer update, thanks to Olaf Kock i found out the solution for my MacOs and zsh terminal

i have two options, first which will start these three scripts celery.sh, flower.sh, start.sh

osascript -e 'tell app "Terminal" to do script "cd /Users/oleg/Desktop/auth &&
./celery.sh"'
osascript -e 'tell app "Terminal" to do script "cd /Users/oleg/Desktop/auth &&
./start.sh"'
osascript -e 'tell app "Terminal" to do script "cd /Users/oleg/Desktop/auth &&
./flower.sh"'

i also found it redundant, because now, i have 4 scripts, and with this update, i can start all these 3 terminals from one script

ultimatestarter.sh

osascript -e 'tell app "Terminal" to do script "activate () { 
                  . /Users/oleg/Desktop/auth/venv/bin/activate
                  } 
activate 
cd /Users/oleg/Desktop/auth/projectname
celery -A projectname worker -l info"'

osascript -e 'tell app "Terminal" to do script "activate () { 
                  . /Users/oleg/Desktop/auth/venv/bin/activate
                  } 
activate 
cd /Users/oleg/Desktop/auth/projectname
celery -A projectname flower --port=5555"'

osascript -e 'tell app "Terminal" to do script "activate () { 
                  . /Users/oleg/Desktop/auth/venv/bin/activate
                  } 
activate 
cd /Users/oleg/Desktop/auth/projectname
python manage.py runserver 0.0.0.0:8000"'

1 Answer 1

1
  1. figure out, which terminal you'd like to start (I'm using xterm as an example)
  2. check your terminal's man page for the actual command to start it with an argument (optionally: To stay open once the command finished)
  3. execute the commands in the background (&)

For xterm this might be something like

xterm -e /bin/bash -ls -c "./celery.sh" &
xterm -e /bin/bash -ls -c "./flower.sh" &
xterm -e /bin/bash -ls -c "./start.sh" &

Sprinkle in pause, if necessary.

Sign up to request clarification or add additional context in comments.

5 Comments

can you help with figuring out this command for zsh terminal? If i do the same with zsh, zsh -e /bin/bash -ls -c "./celery.sh" it returns error /bin/bash:1: command not found: \M-J\M-~\M-:\M->
is it neccesary to use & symbol? in my case, it works without it
isn't zsh a shell (e.g. alternative to bash) rather than a terminal application (that would run the shell)? For me, the same command works well if I use KDE's konsole to stand in for xterm
i'm not sure about the difference
If you replace /bin/bash with /bin/zsh it might work. Otherwise check where zsh is installed: which zsh.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.