Skip to content

Instantly share code, notes, and snippets.

@solarsailer
Last active February 6, 2017 18:41
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 solarsailer/ba9cb0a1d76cc4f2fb901024ccb4116d to your computer and use it in GitHub Desktop.
Save solarsailer/ba9cb0a1d76cc4f2fb901024ccb4116d to your computer and use it in GitHub Desktop.
Open current Finder window in iTerm (for Finder toolbar usage)
on run
tell application "Finder"
try
set targetPath to (quoted form of POSIX path of (folder of the front window as alias))
on error
set targetPath to "~"
end try
end tell
my openTerminal(targetPath)
end run
on openTerminal(targetPath)
set targetCommand to "cd " & targetPath & ";clear;"
tell application "iTerm"
activate
set targetWindow to current window
if targetWindow is equal to missing value then
set targetWindow to (create window with default profile)
else
tell targetWindow
set newTab to (create tab with default profile)
end tell
end if
tell current session of targetWindow
write text targetCommand
end tell
end tell
end openTerminal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment