In my case I just wanted a button on the Finder toolbar that opens up the current folder in the default terminal.
#!/usr/bin/env bash
####################
# Description: Get the path of the most recently used Finder window
# Author: Ancapistani
# Version: 1.0.0
####################
osascript -e 'tell application "Finder"'\
-e "if (${1-1} <= (count Finder windows)) then"\
-e "get POSIX path of (target of window ${1-1} as alias)"\
-e 'else' \
-e 'get POSIX path of (desktop as alias)'\
-e 'end if' \
-e 'end tell';
I have this saved as `fpwd` in my shell.Is that standard now, or did I add it long ago and forget?