Rails Development on OSX: Applescript Automated Startup

Posted by bitbutter on June 26, 2007

I’m starting to notice that getting to work on a rails project after you’ve booted up your mac is a tedious business due to all the applications and processes you need to set off. Here some AppleScripted automation is welcome. There are some very useful guides on this subject already; i’m adding my own variation to the pile.

It makes some assumptions about your development environment:

  1. You have iTerm installed
  2. You’re using TextMate as your editor
  3. You have Firefox installed (as well as Safari)
  4. You have installed the ZenTest gem

Check the opening comments for basic config and installation instructions.

-- Edit app_dir to match the name of your rails app's folder
-- Edit rails_dir if necessary.
-- Save this file as 'yoursitename.scpt' (i put mine in ~/Documents/Scripts)
-- Reopen the .scpt file in Script Editor and choose 'Save as'
-- Choose your preferred save location (i chose the desktop).
-- Choose 'application' as the file format
-- Tick 'Run Only' and make sure the other options are unticked.
-- Save. Double clicking the resulting file will run the script.
-- Bitbutter 2006

set app_dir to "yoursitename"
set rails_dir to "~/sites/"
set app_path to rails_dir & app_dir
set app_url to "http://localhost:3000"
tell application "iTerm"
activate
tell first terminal
tell last session
write text "cd " & app_path & ";script/server"
set name to "server"
set background color to {200, 200, 3000}
set foreground color to {40000, 40000, 60000}
end tell

launch session "Default Session"
tell last session
write text "cd " & app_path & ";script/console"
set name to "console"
end tell

launch session "Default Session"
tell last session
write text "cd " & app_path & ";autotest -rails"
set name to "autotest"
end tell

launch session "Default Session"
tell last session
write text "cd " & app_path & ";mate ."
set name to "Misc"
end tell
end tell
end tell
delay 4
tell application "Firefox"
Get URL app_url inside window 1
end tell
tell application "Safari"
set url of document 1 to app_url
end tell
Trackbacks

Use this link to trackback from your own site.

Comments

Leave a response

Comments