Skip to content

Instantly share code, notes, and snippets.

@johnlauck
Created August 19, 2009 20:53
Show Gist options
  • Save johnlauck/170643 to your computer and use it in GitHub Desktop.
Save johnlauck/170643 to your computer and use it in GitHub Desktop.
Open a rails project terminal session using this AppleScript
(*
Open Project
Open a Rails Project
opens git-sh, console, server, autospec and a command line
*)
on run
set dirs to {}
set commands to {}
set end of dirs to "/Users/john/code/rm"
set end of commands to "git-sh"
set end of dirs to "/Users/john/code/rm"
set end of commands to "script/console"
set end of dirs to "/Users/john/code/rm"
set end of commands to "script/server"
set end of dirs to "/Users/john/code/rm"
set end of commands to "AUTOFEATURE=true autospec"
set end of dirs to "/Users/john/code/rm"
set end of commands to "pwd"
repeat with index from 1 to count dirs
--set command to item index of commands
do_project(item index of dirs, item index of commands)
end repeat
end run
on new_terminal_tab()
tell application "Terminal" to activate
tell application "System Events" to tell process "Terminal" to keystroke "t" using command down
end new_terminal_tab
on new_terminal_window()
tell application "Terminal" to activate
tell application "System Events" to tell process "Terminal" to keystroke "n" using command down
end new_terminal_window
-- this subroutine does the actual work
--
on do_project(the_path, the_command)
--set the_path to POSIX path of this_item
tell application "Terminal"
if (count of windows) is 0 then
my new_terminal_window()
end if
activate
my new_terminal_tab()
do script with command "cd " & quoted form of the_path in window 1
do script with command the_command in window 1
activate
end tell
end do_project
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment