While working on a Rails project I always have at least 4 different Terminal tabs that I use for
- spork server
- autospec
- ./script/server
- command line stuff (generators and general shell commands)
Setting up the tabs all the time is kind of a boring and repetitive task. This truly deserved some automation and it was the perfect excuse for writing my first AppleScript.
After some googling around I came up with this bash/AppleScript to do these tasks for me (and also open up TextMate):
#!/bin/bash
if [ $# -ne 1 ]; then
PATHDIR=`pwd`
else
PATHDIR=$1
fi
/usr/bin/osascript <<EOF
on new_terminal_tab()
tell application "System Events" to tell process "Terminal" \
to keystroke "t" using command down
end new_terminal_tab
set actions to {"spork rspec", "autospec", "./script/server"}
tell application "Terminal"
do script with command "cd $PATHDIR && mate . && clear" \
in selected tab of the front window
repeat with action in actions
my new_terminal_tab()
do script with command "cd $PATHDIR && " & action \
in selected tab of the front window
if action contains "spork" then
delay 7
end if
end repeat
end tell
EOF
If only I had used the right search words I would have found Nick Rutherfor had been through the same situation.


