Last active
December 13, 2015 19:39
-
-
Save matthewmcvickar/4964647 to your computer and use it in GitHub Desktop.
Get the path of the frontmost Finder window. If it is within the user’s folder, replace the `/Users/USERNAME/` with `~/` so that the path can be shared with others.
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
tell application "Finder" | |
tell application "System Events" to set current_user to name of current user | |
set AppleScript's text item delimiters to "/Users/" & current_user | |
try | |
return "~" & text item 2 of POSIX path of (target of front Finder window as text) | |
on error | |
return POSIX path of (target of front Finder window as text) | |
end try | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment