Skip to content

Instantly share code, notes, and snippets.

@asbubam
Forked from AndrewTerry/iTermRails.scpt
Last active December 15, 2015 21:59
Show Gist options
  • Save asbubam/5329274 to your computer and use it in GitHub Desktop.
Save asbubam/5329274 to your computer and use it in GitHub Desktop.
$osascript iTermRails.scpt
property railsFolder : "/Users/asbubam/dev/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 last terminal
launch session "Default"
tell last session
write text "cd " & railsProject & "/" & command
set name to tabTitle
end tell
end tell
end newTab
on newTabWithPath(tabTitle, path)
tell application "iTerm" to tell last terminal
launch session "Default"
tell last session
write text "cd " & railsProject & path
set name to tabTitle
end tell
end tell
end newTabWithPath
tell application "iTerm"
activate
-- close the session
-- terminate the first session of the last 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
make new terminal
activate
my newTab("public", "public")
my newTab("controllers", "app/controllers")
my newTab("models", "app/models")
my newTab("views", "app/views")
my newTab("console", "")
my newTab("log", "log")
my newTab("extra", "")
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