Thursday, April 12, 2012

# cdf: cd's to frontmost window of Finder (by Yarko)

copy the following in ~/.bash_profile

# cdf: cd's to frontmost window of Finder
cdf ()
{
    currFolderPath=$( /usr/bin/osascript <<"    EOT"
        tell application "Finder"
            try
                set currFolder to (folder of the front window as alias)
            on error
                set currFolder to (path to desktop folder as alias)
            end try
            POSIX path of currFolder
        end tell
    EOT
    )
    # ignore the cd if it's my desktop
    if [ "$currFolderPath" != "$HOME/Desktop/" ]
    then
        echo "cd to \"$currFolderPath\""
        cd "$currFolderPath"
    else
        echo "no finder path to cd to..."
    fi
}

2 comments:

Yarko said...
This comment has been removed by the author.
Yarko said...

I also found this complementary (free) app - Go2Shell

Be sure to read the short documentation.

To usefully install it, simply drag it from your applications to your finder toolbar.

Enjoy both ways of syncing finder & shell directories!

Contributors

google