OS X Tip: Change shell to that of frontmost Finder window

I was looking for any integration between Finder and Git (because I like GUIs sometimes. (I know about GitX.))

I came across this instead, a bash function (which works in zsh) that changes directory to that of the frontmost Finder window. It's convenient!

cdfinder() {
  cd "$( /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 home folder as alias)
      end try
      POSIX path of currFolder
    end tell
    EOT
    )"
}

Reference: asktherelic.com/.../osx-terminal-and-finder-integration/


Comments
Posted by: Uldis Bojars §

Alternatively, just drag the folder icon from the title part of that Finder window (at the top, to the left of the name of the current folder) into the Terminal window.

As a result, the path to that folder will be pasted into the Terminal window.

2009-11-22 @ 20:20:37
URL: http://captsolo.net
Posted by: Johan §

A tip for those who have adobe products installed,

running osascript in 32-bit mode helps it from stalling on the script additions adobe makes

arch -i386 osascripts

2010-02-06 @ 14:50:21
Posted by: Abhinay §

Nice hack!

I use 'cd to..' for this -
http://code.google.com/p/cdto/

2010-02-12 @ 23:04:17
URL: http://abhinay.wordpress.com
Posted by: §

good

2011-06-03 @ 12:52:01

Comment the entry:

Name: (required, possibly pseudonym)
Remember me (cookie)

E-mail: (not required, never published, solely for me to reply to you in person)

URL:

Comment:

RSS 2.0