Skip to content

Instantly share code, notes, and snippets.

@lukeledet
Created August 12, 2011 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukeledet/1142371 to your computer and use it in GitHub Desktop.
Save lukeledet/1142371 to your computer and use it in GitHub Desktop.
Thor script to get setup in your rails environment in iTerm
##
# This thor script launches an applescript that starts new tabs in iTerm for
# rails server, rails console and runs the test suite based on the directory
# that the script is run from.
#
# Installation:
# thor install rails.rb
#
# Usage:
# thor rails:iterm
#
# @author Luke Ledet <luke@lootbox.org>
class Rails < Thor
desc "iterm", "start up the current rails application in several iterm tabs"
def iterm
cwd = Dir.pwd
applescript = <<-AS
set project_dir to "#{cwd}"
tell application "iTerm"
activate
set term to current terminal
tell term
set _session to current session
tell _session
write text "cd " & project_dir
write text "rails server"
end tell
launch session "Default"
set _session to current session
tell _session
write text "cd " & project_dir
write text "rails console"
end tell
launch session "Default"
set _session to current session
tell _session
write text "cd " & project_dir
write text "rake"
end tell
end tell
end tell
AS
`echo '#{applescript}' | osascript`
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment