I’m quite happy with my Terminal.app setup right now for the Rails projects I’m working on and wanted to share the bits and pieces I use.
First, I found a SIMB plugin for Terminal that’ll show the tab’s title in the tab instead of the running process. I use the plugin with a simple title helper in my .bash_profile to set the title simply.
function title () {
unset PROMPT_COMMAND # more on this later
echo -ne "\e]0;$1\a"
}
# Usage:
# title 'my title'
function set_window_and_tab_title {
local title="$1"
[[ -z "$title" ]] && title="root"
echo -ne "\e]0;${title}\a"
}
PROMPT_COMMAND='set_window_and_tab_title "${PWD##*/}"'
That’s why I unset PROMPT_COMMAND in my title function, so it won’t auto update when I choose to set it manually using the title function.
The 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 iTerm.
It will open the tabs I usually use when doing Rails development and set the title of each tab using the above mentioned functions. You need to enter you projects root directory and the projects you want to have easy access to. I’ve added some comments to the AS code to help you out.
This is the script I’m using when I start my local Rails development server. It will automatically detect the next available port starting at the default port 3000 so I can have multiple servers running without remembering what ports that are already busy.
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