Toast Driven

← Back to October 9, 2009

Scripting tmux

In my day-to-day work, I find myself needing full mini-environments for several of the projects I work on. Frequently, I'll need to pop a handful of terminals and start various daemons or do environment prep for working in them.

In the past, after trying several things, I ended up using Applescript to launch Terminal.app, pop tabs and load bits up. But I hated working with it, it would frequently drop portions of the setup and was obviously platform-specific. Since I had to setup a loaner laptop anyhow, it dawned on me that I could use a terminal multiplexer instead. I had used screen in the past for administration bits but never really enjoyed it.

However, Alex turned me onto tmux, a modern BSD-licensed multiplexer. After poking at it for about a half hour, I was able to duplicate and improve on everything I had before. Without further ado:

My .tmux.conf file looks like:

Then I created shell scripts to build the environments for me. In this case, to setup my Haystack dev environment, the script looks like:

I'm happy because it works beautifully, reads well and works under Mac OS X and Linux. There might be better ways but this is mine and I like it.

Pixel Toast