Created
June 16, 2016 07:13
-
-
Save claczny/39bb50364dcfb1b8367e0d5d28cf57e7 to your computer and use it in GitHub Desktop.
Opening iTerm From a Finder Directory
This file contains 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 {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" | |
activate | |
try | |
set w to the current window | |
on error | |
set w to (create window with default profile) | |
end try | |
tell w | |
set t to (create tab with default profile) | |
tell current session of t | |
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
This code is motivated by peterdowns.com/posts/open-iterm-finder-service.html and integrates the changes in the API for iTerm2 Build 3.0.0.
Comments are welcome!