Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to open a series of new terminal window, and run commands in a single script?

Every day I do the following commands:

[0] Start terminal

  1. Open window -> memcached
  2. Open window -> redis-server
  3. Open window -> memcached
  4. Open window -> devo
  5. Open window -> cd /some/path
  6. /some/path$ -> rails s --port=3002
  7. Open window -> cd /other/path
  8. /other/path$ -> rails s --port=3000

Can these steps be accomplished in a single script? I'm losing my mind doing these steps every time I restart my system

like image 888
JZ. Avatar asked Dec 28 '22 12:12

JZ.


1 Answers

Create an applescript. You will just need to run the applescript and it'll do all that for you :

tell application "Terminal"
    activate
    do script "memcached" in window 1
    do script "redis-server" -- Each do script opens a new window
    do script "memcached"
    do script "devo"
    do script "cd "
    do script "rails s --port=3002" in window 1 -- does script in last opened window
    do script "cd "
    do script "rails s --port=3000" in window 1 -- does script in last opened window
end tell

Save it as an Application so you can double click it to run it. You could also assign it to start on system start or even to a shortcut with a necessary third party program.

like image 105
Kassym Dorsel Avatar answered Dec 31 '22 14:12

Kassym Dorsel