Open Terminal Here
In a Mac OS X Hints Weblog entry last week, my colleague Rob Griffiths outlined a way to quickly change the working directory in Terminal—the directory you’re “in”—to the currently viewed folder in the Finder. As Rob put it:
As someone who works with the Terminal a lot, I often find myself wanting to do things between the Terminal and the Finder. For example, there are times when I want to open the current Terminal directory in the Finder. That’s actually pretty simple to do—just type open . (note the trailing dot!) and press Return. The Finder will activate with the proper folder opened. Most of the time, though, it seems what I want to do is work with the current Finder folder in the Terminal. The solution to that challenge isn’t quite so simple.
Rob then went on, in typical Mac OS X Hints style, to show you how to create your own solution to this dilemma using Mac OS X’s built-in technologies; in this case, a combination of Automator and AppleScript. If you’re a frequent user of Terminal, Rob’s “hint” teaches you how to use these features while also providing a useful tool.
But—you knew there was a “but” coming, right?—if there’s one thing I’ve learned over the years writing Mac Gems , it’s that there’s always a market for an easier, or even just a different, solution. As Macworld Forums member HumanJHawkins wrote in a forum thread about Rob’s column:
Does anyone know how to edit the contextual menus in OS X? In Windows, all you would do is go into the contextual menu for the object type “Folder” and add “cmd” as an appropriate handler (and give it an intuitive name like “Command Prompt Here..."). Then when you right click on a folder, you see a menu option for “Command Prompt Here...” which will open a command window at that location. Surely there is an easy way to make “Terminal” the handler for folders in OS X, no? Anyone know how?
As it turns out, it’s even easier than that. As with many OS X “needs,” you’ll find that a clever developer has already provided the solution. In fact, there are at least two solutions out there, each of which takes a different approach.
My favorite—and a utility I’ve been using for years now—is PyeHouse Development’s Terminal Here Plugin 0.95 ( ; free), which does exactly what our forums member has requested: After installing Terminal Here Plugin, if you Control/right-click on a folder (or inside an open window) in the Finder, you’ll see a new option in the resulting contextual menu: Open Terminal Here . Choosing this item launches Terminal (or opens a new Terminal window if Terminal is already running) and changes the working directory to the selected folder. (If you’ve never installed a contextual menu plugin before, you simply drop it into ~/Library/Contextual Menu Items and then log out and log back in.)
For those who don’t use contextual menus much, perhaps a more useful option is Marc Liyanage’s Open Terminal Here ( ; free, donations accepted), an AppleScript-based application designed to be placed in the toolbar or sidebar of Finder windows. You can use it in one of two ways: If you’re currently “in” the Finder folder you want to use in Terminal, you simply click the Open Terminal Here icon in the toolbar or sidebar of that Finder window—you’ll briefly see Open Terminal Here in the Dock as it launches and quits, and then a new Terminal window will open with that Finder folder as the current working directory. The second way to use this utility—especially useful if you aren’t currently viewing the desired Finder window—is to drag a Finder folder onto the Open Terminal Here icon in the Finder (or in the Dock, if you’ve added Open Terminal Here to the Dock). Again, a new Terminal window will be opened with that folder as the current working directory.
One quirk common to both Terminal Here Plugin and Open Terminal Here is that they both open a new Terminal window, even if one is already open. In other words, you can’t use one of these solutions to change the working directory for a Terminal window in which you’re already working. (To do that, you can always use the old Terminal standby: type
cd—including the trailing space—then drag the desired folder into the Terminal window, then press return.) And there’s also the fact that by using one of these utilities, you’re not going to learn about cool Mac OS X technologies such as Automator and AppleScript, as you would by using the procedure in Rob’s article. But for those, like our forum member, who want an automated utility without the do-it-yourself fuss, Terminal Here Plugin and Open Terminal Here are handy solutions.
Terminal Here Plugin is compatible with Mac OS X 10.2 and later. Open Terminal Here is compatible with Mac OS X 10.1 and later.