Skip to content

Instantly share code, notes, and snippets.

@nayyarv
Created September 8, 2015 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nayyarv/dc69a7d81fdc506d0c78 to your computer and use it in GitHub Desktop.
Save nayyarv/dc69a7d81fdc506d0c78 to your computer and use it in GitHub Desktop.
OS X bash: Change directory to front most finder window. Copy into .bashrc. Found on stackoverflow.
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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment