But you could also put function in configure file for bash.
The way I do it: open terminal and make sure you are in your home directory that is default.
type in Terminal nano .bash_profile copy my script and paste it.
restart Terminal and type in Terminal cdf.
You could see in the script the function name is pwdf. To make it work we use alias (bash) that you
could see in the last row in the script.
pwdf only give you POSIX path of (target of Finder window 1) as string
and the alias cdf do the magic to add cd before pwdf.