Hacker News new | ask | show | jobs
by aliencat 2709 days ago
This one is pretty useful!

Open current OSX Finder directory in Terminal:

  cdf () {
        target=`osascript -e 'tell application "Finder" to if (count of Finder windows) > 0 then get POSIX path of (target of front Finder window as text)'`
        if [ "$target" != "" ]
        then
                cd "$target"
                pwd
        else
                echo 'No Finder window found' >&2
        fi
}
2 comments

And `open .` does the opposite: opens Finder to your current directory.
can't you just wite "cd" and drag the folder into the terminal?
Yes, but that's a royal pain. 'cdf' are 3 adjacent keys.