Jun
12
OS X Service – Terminal Here
Filed Under 42 (Life the Universe & Everything) on June 12, 2013 at 3:34 pm
I regularly find myself navigating to a folder in the Finder and then wanting to quickly get a Terminal window in the same location. In the past I would open a Terminal window, type cd
and a space, then drag and drop the folder in question from the Finder into the Terminal and hit enter. Thanks to OS X’s great drag-and-drop support that works, and while it is easier than typing out the whole path (even with tab-complete), it’s still quite cumbersome.
Today inspiration hit me – the open
command should let me open a folder with the Terminal, so I tested it, and it does. Armed with this simple command line solution I opened up Automator and threw together a simple OS X service that takes a folder as input. The service has only one action, a Run Shell Script
action with the shell set to bash
, the input passed as arguments, and the following content:
for f in "$@" do /usr/bin/open "$f" -a /Applications/Utilities/Terminal.app/ done
It will only take seconds to re-create this service yourself, but for convenience, I’ve zipped up my copy of the service and am attaching it to this post. Install it by unzipping and adding to either ~/Library/Services/
(for just yourself) or /Library/Services/
(for all users).
Once the service is installed it will show up in the Services menu in the Finder when ever you have one or more folders selected:
You can also get to the service by right-clicking on any folder in the Finder:
Finally – if you keep the optional Path Bar shown in the Finder you can also right-click on a Folder there to access the service (including the folder you are in):
That’s neat – it would be even better if it were in the right-click menu, but having it in the Path Bar is nearly as good. I’ve been looking for a new way to do this – probably removing XtraFinder in Mavericks, and “Terminal Here” is the only thing it did that I need to replace.