Running a command in a new Mac OS X Terminal window

We’ve been trying to figure out how to open multiple terminals on OSX and running different bash commands in each.

Most examples online show how to open a terminal or how to run a command in a home directory but in our Node app, we wanted to open two terminals in the current directory and execute two different npm run scripts

So what we did was

  1. Create a file in the root directory of the app called – start.sh
  2. Add the following lines in start.sh file to start a terminal and run a command
    ttab eval 'cd "/Users/You/Documents/WWW/myapp"; nodemon app.js'
    ttab eval 'cd "/Users/You/Documents/WWW/myapp"; gulp'
  3. Open the terminal and cd to the path of start.sh and run
    sh start.sh

Did that work for you?

Have an idea?

Let us transform your idea into a Scalable Product

Phone

424-388-1279

Address

1450 2nd St, Santa Monica, CA 90401