Skip to content

Instantly share code, notes, and snippets.

@MaartenS
Created February 22, 2016 19:49
Show Gist options
  • Select an option

  • Save MaartenS/1dbc82f4bc478e544422 to your computer and use it in GitHub Desktop.

Select an option

Save MaartenS/1dbc82f4bc478e544422 to your computer and use it in GitHub Desktop.

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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment