aku-aku: v.. To move a tall, flat bottomed object (such as a bookshelf) by swiveling it alternatively on its corners in a "walking" fashion. [After the book by Thor Heyerdahl theorising the statues of Easter Island were moved in this fashion.] source: LangMaker.com. Aku Aku also has another meaning to the islanders: a spiritual guide.
« two things on academics | Main Page | HR 811 Electronic Voting Bill »
automatic terminals in os x with ruby
Posted by dav at 2007 March 16 07:26 AM
File under: Geek

When working on my Ruby on Rails projects, I always like to open 7 windows on my OS X desktop. My IDE (currently Idea with the Ruby Plugin), my firefox web browser, and five terminal windows. One for command line interface, two for tailing the test and development logs, and two for running mongrel and a selenium server. I use two monitors, and I like to set the five terminal windows in certain places on the desktop. I quickly grew tired of opening each terminal window and placing it, resizing it, cd-ing to the right directory and running the right command, especially since it was all the same each time except for the project directory.

The OS X Terminal.app allows you to save a terminal window to a .term file. This is an XML file that contains all of the window configuration options including commands to run when opened. You can open a saved .term file by double clicking on its icon or running open mysavedwindow.term from the command line and it restores everything.

So I wrote two ruby scripts. One takes a .term file and outputs a ruby hash of window settings, the other takes a list of these hashes and opens each window represented by them. When I run the second script I also give it the name of my project and the windows are opened for that project.

The two files are parse_term.rb and terminals.rb. To use them, first manually place your terminal windows as you'd like them to come up each time. Then save each one to a .term file. Run the .term files through the parse_term.rb utility (ruby parse_term.rb saved.term). Collect the output from this and stick it in the appropriate place in the terminals.rb script.

Now edit the terminals.rb script further. Add in the :command strings so each has what you want to run when that window is open. Change the project_path directory to match your system. Run this script, passing a project name as a parameter.

This was a quick hack to meet my needs, but if you're the kind of person who likes to open multiple terminal windows when working, you'll probably be able to customize this to your needs easily.

Currently I run this from an already open terminal window, but I'd like to be able to run it from Quicksilver (perhaps using command-space period <project name> tab terms enter). Anyone know how to set that up? My AppleScript and Quicksilver skills are weak.



I've been desparately wanting a way to save terminal window positions & commands for *years*. I'd have been 10% more productive at 6a if I'd known I could do that.

Posted by: Ezra Cooper on March 16, 2007 03:57 PM

Well, if it makes you feel any better, you had already left six apart by the time I figured it out myself.

By the way, to use these scripts you also need to install the erubis ruby gem.

Posted by: dav on March 16, 2007 05:25 PM

Post a new comment:

Thanks for signing in, . Now you can comment. (sign out)

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Remember me?