Last active
August 27, 2015 22:46
-
-
Save enkeboll/728f7fa1804bb00ff98d to your computer and use it in GitHub Desktop.
Open Folder in iTerm2 from Finder
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
#!/usr/bin/osascript | |
# This is my version of | |
# http://peterdowns.com/posts/open-iterm-finder-service.html | |
# modified for iTerm 2.9+ | |
# Create this as an "Application", save it as a .app file, and | |
# drag it onto the Finder window while holding the command key | |
# (in Yosemite, the command and option keys) | |
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) | |
set wasRunning to false | |
if application "iTerm" is running then | |
set wasRunning to true | |
end if | |
tell application "iTerm" | |
activate | |
if wasRunning then | |
tell current window | |
create tab with profile "Default" | |
end tell | |
end if | |
set CDcommand to "cd " & theDir & "; clear;" | |
try | |
tell current session of current window | |
write text CDcommand | |
end tell | |
on error | |
create window with profile "Default" | |
tell current session of current window | |
write text CDcommand | |
end tell | |
end try | |
end tell | |
end CD_to |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment