Skip to content

Instantly share code, notes, and snippets.

@brake
Created May 22, 2016 13:38
Show Gist options
  • Select an option

  • Save brake/197b42594f2ee81cf647929eddde52e7 to your computer and use it in GitHub Desktop.

Select an option

Save brake/197b42594f2ee81cf647929eddde52e7 to your computer and use it in GitHub Desktop.
Open a new iTerm2 tab with folder selected in Finder. If iTerm was not previously started - starts it.
-- Stefan van den Oord, 2010-12-29
-- Constantin Roganov 2015-06-27
-- The "cd to" command for iTerm2 (added: opening in new tab of iTerm 2
tell application "Finder"
set _cwd to POSIX path of ((folder of (front window)) as alias)
end tell
tell application "iTerm"
activate
try
set _term to «class Ctrm»
on error
set _term to (make new «class Ptrm»)
end try
tell _term
«event ITRMLNCH» given «class Pssn»:"xterm"
set _session to «class Cssn»
end tell
tell _session
«event ITRMWrte» given «class iTxt»:"pushd \"" & _cwd & "\""
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment