AppleScript to open iTerm tabs for Rails development
Update: This script is ported (and improved) to work with OSX Leopards’ Terminal.app.
I never really liked iTerm because of slow redrawing, ugly text anti aliasing and not reflowing text when resizing the window.
After reading some interviews on a Rails site today and saw that a lot of people are using iTerm i wanted to give one more try (because I’d really like a tabbed terminal).
It has improved a lot the latest months and seems really usable now. To make Rails development easier, I hacked together a small AppleScript what will ask you for the path to the Rails directory you want to use and then open four new tabs with Server/Mongrel, Console, Autotest and the directory itself. I thought it could be useful for others as well so here you go:
Save as an .app and run from Quicksilver:
global rails_dir
tell application "iTerm"
activate
set rails_dir to the text returned of (display dialog ¬
"Please Enter the Path to Your Rails Directory" default answer ¬
"~/Projects/" as text)
if (count of terminal) = 0 then make new terminal
my open_tab("Server", "&& ./script/server")
my open_tab("Console", "&& ./script/console")
my open_tab("Autotest", "&& autotest")
my open_tab("Rails Directory", "")
end tell
on open_tab(title, command)
tell application "iTerm" to tell first terminal
launch session "Default"
tell last session
write text "cd " & rails_dir & command
set name to title
end tell
end tell
end run_command


Fri 20/7/07, 13:14
Just wait for leopard. It’s got some tabbed Terminal goodness goin on./
Fri 20/7/07, 15:09
Ya, that’s was actually one of the features I’m looking forward to since I didn’t like iTerm but seems like I don’t have to wait until October now :)/
Sun 19/8/07, 19:17
THX! I tried once to write something myself, but as a total AppleScript newbie I couldn’t figure how exactly to do this./
Sat 12/7/08, 11:17
[...] last piece is an updated version of my old Rails Term-script for iTerm which has been updated (and improved) for the Terminal in Mac OS X Leopard instead of [...]/