views:

12449

answers:

13

Is there something similar to the "Open Command Window Here" Windows Powertoy for Mac OS? I've found a couple plugins through a google search but wanted to see what works best for developers out there.

+6  A: 

I use the script from here. Just drag&drop it to finder's toolbar. It may not be the nicest solution but it is simple and it works.

d0k
i use that script too - its good enough for most things.
Chii
I don't remember where I got mine, but I use a similar one that has a slightly different icon (and I'm sure the same functionality). Works well for me. I often to the reverse though and am in a terminal and use "open ." to open the current directory in finder.
Ted Naleid
+4  A: 

Also, you can copy an item from the finder using command-C, jump into the Terminal (e.g. using Spotlight or QuickSilver) type 'cd ' and simply paste with command-v

Henrik Hartz
+2  A: 

If you install Big Cat Scripts (http://www.ranchero.com/bigcat/) you can add your own contextual menu (right click) items. I don't think it comes with an Open Terminal Here applescript but I use this script (which I don't honestly remember if I wrote myself, or lifted from someone else's example):


on main(filelist)
    tell application "Finder"
     try
      activate
      set frontWin to folder of front window as string
      set frontWinPath to (get POSIX path of frontWin)
      tell application "Terminal"
       activate
       do script with command "cd \"" & frontWinPath & "\""
      end tell
     on error error_message
      beep
      display dialog error_message buttons ¬
       {"OK"} default button 1
     end try
    end tell
end main


Similar scripts can also get you the complete path to a file on right-click, which is even more useful, I find.

iayork
+40  A: 

This:

http://code.google.com/p/cdto/

It's a small app that you drag into the Finder toolbar, the icon fits in very nicely. It works with Terminal, xterm (under X11), iterm.

redacted
Nice. The perfect complement to "open ." in the terminal. I wish it could open an new tab though, instead of a new window.
Pat Niemeyer
+13  A: 

Clarification (thanks @vgm64): if you're already in Terminal, this lets you quickly change to the topmost Finder window without leaving Terminal. This way, you can avoid using the mouse.

I've added the following to my .bash_profile so I can type cdff in Terminal at any time.

function ff { osascript -e 'tell application "Finder"'\
 -e "if (${1-1} <= (count Finder windows)) then"\
 -e "get POSIX path of (target of window ${1-1} as alias)"\
 -e 'else' -e 'get POSIX path of (desktop as alias)'\
 -e 'end if' -e 'end tell'; };\

function cdff { cd "`ff $@`"; };

This is from this macosxhints.com Terminal hint.

PCheese
I might be getting you wrong here, but couldn't you just say `open .`?
Fabian Steeg
These functions allow the terminal to cd to the what ever directory a the topmost (but background) Finder window has w/o leaving the Terminal. Unexpected bonus, PCheese. Thanks!
vgm64
+1  A: 

It's a bit more than you're asking for, but I recommend Cocoatech's Path Finder for anyone who wishes the Finder had a bit more juice. It includes a toolbar button to open a Terminal window for the current directory, or a retractable pane with a Terminal command line at the bottom of each Finder window. Plus many other features that I now can't live without. Very mature, stable software. http://cocoatech.com/

+6  A: 

Check out Open Terminal Here. It may be the most similar to "Open Command Window Here." I used >cdto and this is very similar but this seems to be a little better at dealing with Spaces... but not perfect.

What it has that is very nice is the ability to "detect key-down events at the start of the application and used them to modify the behavior of the script" allowing the script to open a new tab in the front most terminal window when invoked by holding down ⌘ key. Neat trick.

Also note PCheese's answer; it is probably more useful for heavy terminal users!

vgm64
A: 

Ok, I realize that this is a bit late... maybe this alternative wasn't available at the moment of writing the post?

Anyway, I've found installing the pos package via Fink (a prerequisite in this case, maybe there is something similar for those who uses MacPorts?) to be the easiest solution. You get two commands:

  1. posd - which gives the current directory of the frontmost Finder window (for which you presumably make an alias cdf=cd posd)
  2. fdc - which switches the current directory of the frontmost Finder window to the Terminal pwd. This is slightly different from 'open .' which always opens a new finder window.

Yes, you have to switch to the Terminal window before writing cdf, but I suppose that's quite cheap comparing to clicking a button in the Finder toolbar. And it works with iTerm as well, you don't have to download a separate Finder toolbar button that opens an iTerm window. This is the same approach as proposed by PCheese, but you don't have to clutter your .bash_profile.

Jonatan Lindén
A: 

There is a bug in the AppleScript on OSX 10.6. (2 terminal windows open). I fixed this by adding the close command after activate. This close the first Terminal window.

on run
    tell application "Finder"
        try
            activate
            set frontWin to folder of front window as string
            set frontWinPath to (get POSIX path of frontWin)
            tell application "Terminal"
                activate
                close
                do script with command "cd \"" & frontWinPath & "\""
            end tell
        on error error_message
            beep
            display dialog error_message buttons ¬
                {"OK"} default button 1
        end try
    end tell
end run
daigoro
Why would you want to close a Terminal window? Won't that destroy whatever work you were doing in it?
Rob Kennedy
A: 

I created a bundle with 3 apps for the finder toolbar. The other two apps do:

  • open Textmate with the current selection
  • open GitX with the current folder

For more information see here: http://nslog.de/posts/71

stigi
+3  A: 

There is an updated version of the very nice and slim Open Terminal Here posted by vgm64 and d0k. The change was made by james david low. He published the new version on his site. Just download OpenTerminalHere.zip, extract it, move the bundle to your Library/Scripts folder and drag it from there to your Finder toolbar.

What is special about it is that it always opens a new tab if a Terminal.app window is already open. Very useful! I also noted that the style of the button of the application better fits the Snow Leopard Finder.app style than cdto posted by redacted did.

pklaus
+3  A: 

An application that I've found indispensible as an alternative is DTerm, which actually opens a mini terminal right in your application. Plus it works with just about everything out there - Finder, XCode, PhotoShop, etc.

Paul Alexander
A: 

.. would it be possible to do the same thing with other apps than finder... e.g. I often need to go to a default dir of Eclipse etc...

jmuf
Maybe. Feel free to ask about it in a new question. This space is reserved for answers to *this* question.
Rob Kennedy