Last active
August 29, 2015 14:19
-
-
Save gwerbin/27edc1c4531a6b95ef1b to your computer and use it in GitHub Desktop.
In Automator, create a new Workflow, add action Run Applescript, and replace the contents of the text box with this entire file. At the top, where it says "Service receives selected ___ in ___" select "Files or Folders" in the first drop-down menu, and "Finder.app" in the second. You can set a keyboard shortcut in System Preferences -> Keyboard …
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 currentSelection to selection | |
set currentFolder to target of front Finder window as text | |
end tell | |
tell application "iTerm" -- this should work if you replace "iTerm" with "Terminal" (untested) | |
if currentSelection = {} then | |
set thePath to POSIX path of currentFolder | |
set targetType to "folder" | |
else | |
set theTarget to item 1 of currentSelection as alias | |
set thePath to POSIX path of theTarget | |
set targetType to kind of (info for (theTarget) without size) | |
end if | |
make new terminal | |
tell the current terminal | |
activate current session | |
launch session "Default Session" | |
tell the last session | |
if targetType is "folder" then | |
write text "cd " & quoted form of thePath | |
else | |
write text "cd " & quote & "$(dirname " & quoted form of thePath & ")" & quote | |
end if | |
write text "clear && pwd" | |
end tell | |
end tell | |
end tell | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment