Skip to content

Instantly share code, notes, and snippets.

@GrantGochnauer
Created August 18, 2015 20:47
Show Gist options
  • Save GrantGochnauer/42ff81ee69ac2a0c3f23 to your computer and use it in GitHub Desktop.
Save GrantGochnauer/42ff81ee69ac2a0c3f23 to your computer and use it in GitHub Desktop.
tell application "Finder"
set pathList to (quoted form of POSIX path of (folder of the front window as alias))
end tell
tell application "System Events"
set isRunning to (exists (processes where name is "iTerm2"))
end tell
tell application "iTerm"
set termCount to count of windows
if termCount is 0 then
set myTerm to (make new window)
else
set myTerm to the current window
end if
-- display dialog termCount
if isRunning and termCount is not 0 then
tell current window
create tab with profile "Default"
tell current session
write text "cd " & pathList
end tell
end tell
end if
activate
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment