News for hackers. Stuff that matters.
Re:Useful command-line scripts for web developers (or anyone... by emson on Friday June 05, 2009 @09:50AM (#643168)
I also use this natty little function in my .bash_profile to cd to the last opened finder location.

This is a script written by a colleague. http://www.visualcortex.co.uk/. Add the following function to your .bash_profile in Apple OSX. Now open a directory in Finder, then open terminal and type cdf, your terminal will now change directory to the same one as the last Finder opened.

    # function to change directory to the one set in the last opened 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
       )
       echo "cd to \"$currFolderPath\""
       cd "$currFolderPath"
    }
Re:Useful command-line scripts for web developers (or anyone... by nileshk on Friday June 05, 2009 @12:54PM (#643497)
I've been using OpenTerminal for this purpose:

http://www.macupdate.com/info.php/id/23173

It gives you an icon in Finder that changes the directory in your terminal to the one in the Finder window. There are some options, like have it open a new terminal, or change the folder using pushd, so you can popd once your done and return to the folder it originally was in.

I like the script you provided, though, as it saves me from having to use the mouse (no button click) and I can easily select which terminal to do it in. Note that I had to remove the quotes around the first EOT to get it to work.

Re:Useful command-line scripts for web developers (or anyone... by yan on Friday June 05, 2009 @10:20AM (#643219)
Conversely, running "open dir/" will open the dir in Finder. I tend to use that a lot.
Re:Useful command-line scripts for web developers (or anyone... by emson on Friday June 05, 2009 @10:50AM (#643274)
yeah useful, also "open `pwd`" to open the current directory
Re:Useful command-line scripts for web developers (or anyone... by judofyr on Friday June 05, 2009 @10:56AM (#643280)
What's wrong with "open ."?
Re:Useful command-line scripts for web developers (or anyone... by emson on Friday June 05, 2009 @11:08AM (#643297)
erm... yes good point!