Skip to content

Instantly share code, notes, and snippets.

@AndrewTerry
Created May 13, 2011 14:21
Show Gist options
  • Save AndrewTerry/970615 to your computer and use it in GitHub Desktop.
Save AndrewTerry/970615 to your computer and use it in GitHub Desktop.
Applescript for creating tabbed iTerm session for Rails development
property railsFolder : "/Users/andrew/Documents/DevProjects/rails_projects/" --update this to reflect your own location
global targetProjectName
global railsProject
-- Creates a new tab with the command passed to it, and sets the title accordingly
on newTab(tabTitle, command)
tell application "iTerm" to tell first terminal
launch session "Default"
tell last session
write text "cd " & railsProject & command
set name to tabTitle
end tell
end tell
end newTab
tell application "iTerm"
activate
-- close the session
terminate the first session of the first terminal
-- ask for the project name
-- (Todo: validate the project folder exists; quit gracefully if not)
set targetProjectName to the text returned of (display dialog "Which project?" default answer "" as text)
set railsProject to railsFolder & targetProjectName
if (count of terminal) = 0 then make new terminal
my newTab("app", "")
my newTab("autotest", "&& autotest")
my newTab("spork", "&& spork")
my newTab("server", "&& rails s")
my newTab("console", "&& rails c")
end tell
-- This does CMD-leftArrow to get back to the command prompt in the project folder
tell application "System Events"
keystroke (ASCII character 28) using command down
keystroke (ASCII character 28) using command down
keystroke (ASCII character 28) using command down
keystroke (ASCII character 28) using command down
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment