Last active
February 6, 2017 18:41
-
-
Save solarsailer/ba9cb0a1d76cc4f2fb901024ccb4116d to your computer and use it in GitHub Desktop.
Open current Finder window in iTerm (for Finder toolbar usage)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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