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