Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way to automate a bunch of terminals starting up at once. I find myself opening several windows and running the same sequence of commands in various tabs. I'd like to stick all this in a single shell file (so I could keep it in version control, share it, etc) rather than have to add it all to a GUI.

Ideally with iTerm, but automating with any terminal program would be interesting to hear about.

share|improve this question
Tmux has worked wonders for me since asking this question. – mahemoff Oct 18 '13 at 17:02
up vote 2 down vote accepted

You could run your shell script from ~/.bashrc. Then no matter which client you use it will be executed when you open a new shell.

share|improve this answer
Sure, but I'm trying to run 20 different scripts, one for each pre-defined tab. – mahemoff Jun 2 '12 at 2:48
In your shell script you could base what code is run on what your ttys for that tab is set to. tty will give you that information. – dhempler Jun 2 '12 at 3:25
Nice, it's /dev/ttys022, so I could write a script to loop from 001 to 030 for example and call a function like init001 etc. I'm still not sure if there's any way to automate the windows though - ie 4 windows in first terminal, 8 in second, etc. – mahemoff Jun 2 '12 at 10:11
You could use some AppleScript with iTerm to automate opening sessions and tabs. – dhempler Jun 2 '12 at 11:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.