Skip to content

Instantly share code, notes, and snippets.

@dalemanthei
Created December 29, 2013 19:33
Show Gist options
  • Save dalemanthei/8173899 to your computer and use it in GitHub Desktop.
Save dalemanthei/8173899 to your computer and use it in GitHub Desktop.
A .bash_profile snippet for Mac OS X from http://brettterpstra.com/2013/02/09/quick-tip-jumping-to-the-finder-location-in-terminal/ with added snippet for Path Finder.
# from http://brettterpstra.com/2013/02/09/quick-tip-jumping-to-the-finder-location-in-terminal/
# cd to the path of the front Finder window
cdf() {
target=`osascript -e 'tell application "Finder" to if (count of Finder windows) > 0 then get POSIX path of (target of front Finder window as text)'`
if [ "$target" != "" ]; then
cd "$target"; pwd
else
echo 'No Finder window found' >&2
fi
}
# And a Path Finder version of the same
cdpf() {
target=`osascript -e 'tell application "Path Finder" to if (count of Finder windows) > 0 then get POSIX path of (target of the front finder window)'`
if [ "$target" != "" ]; then
cd "$target"; pwd
else
echo 'No Path Finder window found' >&2
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment