This is not mine. I can’t remember where I found it. Apologies for no attribution (Mac):
#!/usr/bin/env bash
function cdf() {
#: Change working directory to the top-most Finder window location
cd "$(osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)')";
}
#!/usr/bin/env bash
function cdf() { #: Change working directory to the top-most Finder window location cd "$(osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)')"; }