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 () {<br />
  unset PROMPT_COMMAND # more on this later<br />
  echo___ -ne "\e]0;$1\a"<br />
}

# Usage:<br />
# title 'my title'

Second, I use a technique I saw on how to automatically set the title to display the current working directory as title, but since I use the plugin and helper function above, I could simplify the PROMPT_COMMAND a bit:

function set_window_and_tab_title {<br />
  local title="$1"<br />
  [[ -z "$title" ]] && title="root"<br />
  echo___ -ne "\e]0;${title}\a"<br />
}

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.

Download a zipped version of the AppleScript. Just drag the script to the Script Editor (/Applications/Utilities) to edit it.

All source code for these scripts can also be viewed on Pastie. Let me know if you have any improvements.