Saturday, July 5, 2008

Productivity boost for Rails developers - or - How I work

Here is the shell script I use to start my Rails development environment (requires iTerm and TextMate).
Just replace FULL_PATH_TO_PROJECT_ON_DISK with the path to your project and give it a name: PROJECT_NAME.

It will open iTerm with 4 shell, and it will run:
* Textmate in the root of the project, so that all project files are listed in textmate
* the rails server will be started
* the console will be launched
* the database console will be launched


#!/bin/sh
PROJECT_DIR=FULL_PATH_TO_PROJECT_ON_DISK
PROJECT_NAME=PROJECT_NAME

osascript <<-eof
tell application "iTerm"
make new terminal
tell the last terminal
activate current session

launch session "Default Session"
tell the last session
set name to "$PROJECT_NAME-project-root"
write text "cd \"$PROJECT_DIR\""
write text "mate ."
write text "clear; ls -lah"
end tell

launch session "Default Session"
tell the last session
set name to "$PROJECT_NAME-server"
write text "cd \"$PROJECT_DIR\""
write text "clear"
write text "./script/server"
end tell

launch session "Default Session"
tell the last session
set name to "$PROJECT_NAME-console"
write text "cd \"$PROJECT_DIR\""
write text "clear"
write text "./script/console"
end tell

launch session "Default Session"
tell the last session
set name to "$PROJECT_NAME-database"
write text "cd \"$PROJECT_DIR\""
write text "clear"
write text "./script/dbconsole"
end tell

end tell
end tell

tell application "TextMate"
activate
end tell
eof

No comments: