Have you ever wanted to open a Terminal (or iTerm) immediately into the same directory displayed in the OS X Finder window? You can do this and much more using Gary Kerbaugh's collection of UNIX utilities and Applescripts. Three shell scripts allow greatly increased synergy between the Finder and the command line. These can be supplemented with AppleScript applications that allow you, in one click, to open a Terminal window or iTerm tab in the directory corresponding to that shown in the finder.
These unix utilities include cdf, posd, fdc and rmm.
cdf and posd:
posd is an osascript embedded in a shell script that returns the directory corresponding to the frontmost Finder window. Its real value is when aliased to the command cdf, i.e.:
% cdf='cd "$(/sw/bin/posd)"'The command cdf changes the terminal working directory to match that of the frontmost Finder window.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20030915193326598