Created
August 12, 2012 20:03
-
-
Save ptone/3334103 to your computer and use it in GitHub Desktop.
cd to current finder window
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
# cdf: cd to the directory in the Finder's front window | |
alias cdf='cd "$(~/UNIX/bin/posd)"' |
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
#!/bin/sh | |
thePath="$( osascript<<END | |
try | |
tell application "Finder" to set the source_folder to (folder of the front window) as alias | |
on error -- no open folder windows | |
set the source_folder to path to desktop folder as alias | |
end try | |
set thePath to (POSIX path of the source_folder as string) | |
set result to thePath | |
END | |
)" | |
#thePath="$( echo "$thePath" | /usr/bin/sed 's/ /\\ /g' )" | |
if [ -n "${thePath%/*}" ]; then | |
if [ -d "$thePath" ]; then | |
echo "${thePath%/}" | |
else | |
echo "${thePath%/*}" | |
fi | |
else | |
echo "/" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment