Skip to content

Instantly share code, notes, and snippets.

@nikolay-n
Last active September 15, 2020 15:31
Show Gist options
  • Save nikolay-n/5b57ee09f555c873624a275920fd55d4 to your computer and use it in GitHub Desktop.
Save nikolay-n/5b57ee09f555c873624a275920fd55d4 to your computer and use it in GitHub Desktop.
Open iTerm or Terminal with current Finder path
Launch Automator and select Application, add "Run AppleScript" action and paste code from TermLaunch.scpt, save app as TermLaunch.
You can replace icon /Path/To/TermLaunch.app/Contents/Resources/AutomatorApplet.icns to
/Applications/Utilities/Terminal.app/Contents/Resources/Terminal.icns for example
Use Cmd + Drag to place app on Finder toolbar
on run (input)
set fPath to (quoted form of finderPath())
-- Trying iTerm app
set itermPath to do shell script "mdfind 'kMDItemCFBundleIdentifier == com.googlecode.iterm*'"
if itermPath is not "" then
do shell script "open -a iTerm " & fPath
return
end if
-- Trying terminal app
do shell script "open -a Terminal " & fPath
end run
on finderPath()
tell application "Finder"
set currentPath to the POSIX path of (target of window 1 as alias)
end tell
return currentPath
end finderPath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment