Skip to content

Instantly share code, notes, and snippets.

@dinolupo
Created June 30, 2016 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dinolupo/b992d4035cf2437249c5ae725743ec0d to your computer and use it in GitHub Desktop.
Save dinolupo/b992d4035cf2437249c5ae725743ec0d to your computer and use it in GitHub Desktop.
AppleScript that opens a new iTerm2 at a file or directory selected location in Finder
on run {input, parameters}
tell application "Finder"
set dir_path to quoted form of (POSIX path of (folder of the front window as alias))
end tell
CD_to(dir_path)
end run
on CD_to(theDir)
tell application "iTerm"
set _term to create window with default profile
tell _term
set _session to current session
tell _session
write text "cd " & theDir & ";clear;"
end tell
end tell
end tell
end CD_to
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment