Target of Finder window 1 with Shell command

The command in application Finder target of Finder window 1 could be very useful
in shell scripting or navigation in Terminal.

What if we could only type 3 character long string in Terminal and get target of Finder window 1
Some clever person did and I like to share it with you here.

The script below should be attached to ~/.bash_profile (bash)

Now you could navigate in Finder to any directory and in Terminal you type cdf (return)

I can see that would be quite useful. But…

…please explain to this Terminal novice how to do that.

In bash scripting you could make function

ex.

function hello () {
echo Hello World!
}

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.