Mac OSX Open Terminal Here Service

Mac OSX Snow Leopard has revived the Services menu.

I’ve implemented a really simple Service called “Open Terminal Here”. It’s a small service which becomes available in the context menu of every file and folder in the Finder with an entry called “Open Terminal Here”.

It’s function is really simple, it activated the Terminal application and changes the current directory to selected directory or the containing directory, depending whether you selected a file or folder.

The linked zip file contains a file named: “Open Terminal Here.workflow”
If you would like to change the name appearing in your services menu, just change the name of the file to something else. make sure the extension remains the same. For example: “Any other Name.workflow”.

After you are happy with the services name, copy the resulting file to the directory “Library/Services” in your user’s home directory. Now you can open a Terminal window at the location you’ve just selected, it works for multiple selections too.

Here’s the link to the zip file: Open Terminal Here 0.3.zip

Oh just a little tip, to open the current Terminal.app path you’re at into a Finder window, just type “open .” followed by a return. (Yes, that’s 4 characters, a space and finally a dot.)

Some people have reported some issues while installing this service. Please see the comments for a workaround by j.g. Owen.

Version 0.3:
-Fixed the multiple window problem (courtesy John-Michael Glenn)

Version 0.2:
-should fix a localization problem.

I’ve also created a SVN repository for this little bit of code: http://leenarts.net/svn/opensource/Open%20Terminal%20Here/
When asked for a username and password, just enter empty strings.

26 thoughts on “Mac OSX Open Terminal Here Service

  1. Hi Jeroen,

    I didnt see any Services folder in ~/Library, so I created one, copy “Open Terminal Here.workflow” to that folder, but I still not see the context menu “Open Terminal Here”. What else do I have to do? Please help.

    Thanks,

    D.

  2. Hello Duke,

    I remember having this problem as well.

    My solution was to open the workflow in Automator. Add a space at an empty line in the little script window and save the workflow, overwriting the one originally in the Services folder.

    It seems some process needs to get a nudge. Perhaps restarting the Finder might work as well.

  3. Thanks Jeroen for the reply. I am not sure if I am doing anything wrong, but I still did not see context menu of Open Terminal Here following your instruction. Googling for a while, here is what I did:

    – Open workflow using Automator
    – Go to File – Save as Plug-In
    – Type the desire name (Open Terminal Here)
    – Plug-in for: Finder
    – Save

    Later, the Open Terminal Here will appear in tne context menu, under More – Automator. And it works.

    Is that what you came up with in your system, or you have a context menu right after a right click? (not under More – Automator)?

    Thanks,

    D.

  4. I’ve found a small problem in the Open Terminal Here workflow. It contained an entry with the following contents:
    /System/Library/Automator/Run AppleScript.action/Contents/Resources/Dutch/main.nib

    Maybe that was causing the problem for you. I’ve uploaded version 0.2 with a fix. But as it’s already working for you, I’m wondering your nibPath entry contains in the workflow file.

  5. I checked my version and it shows nibPath pointing to the *right* one (I think):

    /System/Library/Automator/Run AppleScript.action/Contents/Resources/English.lproj/main.nib

  6. Thank you for this wonderful lil utility.

    It worked fine with me. I opened the workflow in Automator and then Click RUN on the top right side. It automatically created the Services folder (It wasn’t there before) and It is all good.

    Thanks again,

    Regards.

  7. Tue 12/08/2009 7:03 pm. Hi. This is what I did to get this useful thing working on my pitiful mini:

    1. Copy the workflow file to ~/library/services (your home directory, library/ervices). If there *is* no “services” directory, first make it. (Stupidly I forgot how make a directory on the Mac and had to open a terminal!)

    2. Then, in the services directory, double-click on the file to open the automator or whatever it is. Like someone advised, harmlessly mutilate the thing with a space in the comments or something, and then exit automator, and it should ask if it should save it, and you answer YES. Actually before I did that, I clicked the green button to run the thing once or whatever that does. … Anyway, I suspect this save wrinkle has something to do with the helpful snow leopard tagging the file as an evil internet file, and saving it makes it no longer an evil internet file. ?

    3. Restart finder perhaps.

    Then it worked good.

  8. Jeroen,

    I’ve just downloaded the file, extracted it, opened it with Automator and SAVE.
    Saving created the Services folder and saved Open Terminal Here.workflow and everything ran smoothly.

    Thanks for sharing !

  9. Thank you – this is a huge saver. I combined these last two approaches. I created the ~/library/services folder, opened up and Automater, did an innocent mod, saved, and it wound up in the right place doing the right thing. Thanks Again!

  10. For some reason when I run the script from the menu I get two Terminal windows opening up. One in my home folder and a second in the folder selected in the finder. Any ideas why? I’m running OS X Snow Leopard.

  11. Jeroen,

    I am just migrating from Windows, and was jonesing for a replacement for Open Command Prompt Here. You Rock!

    dave

  12. Hello Peter, this happens because Terminal.app opens an initial console window on your home folder. If you open Terminal.app manually yourself, you wil see this same effect.

    U haven’t looked into it any further because it hasn’t bothered me. If you come accross a workaround, please post a comment.

  13. No luck for me.
    I run the Workflow in automator, adding a “Get specified Finder folder” and it worked as expected.
    I removed the added action and save.
    I logged out and in.

    I created a new Service for Finder in automator, and added your code.
    Still no luck.

  14. Alex, last week I got a new system, hadn’t installed the workflow myself yet. I tried and it works as advertised.

    A question though, did you have a finder window open with a file or folder selected before looking for the service? Because simple having a Finder window open with nothing selected in it won’t work.

  15. Hi Jeroen, fist time open terminal here, out from finder, it opens terminal in twice, i think it is a small bug, but can’t locate the command
    thx Don

  16. It’s not so much a bug. It’s Applescript activating the Terminal application. When the Terminal App starts it opens a window by default. I haven’t found a way around this yet. But I’m open to suggestions. I imagine something along the lines of detecting if Terminal.app is active. If it’s not, then pass the path as an argument to Terminal.app as an inital path to open the first window on. But since it works for me I didn’t look into this any further yet.


  17. Jeroen:

    It’s not so much a bug. It’s Applescript activating the Terminal application. When the Terminal App starts it opens a window by default. I haven’t found a way around this yet. But I’m open to suggestions. I imagine something along the lines of detecting if Terminal.app is active. If it’s not, then pass the path as an argument to Terminal.app as an inital path to open the first window on. But since it works for me I didn’t look into this any further yet.

    Thank U
    Well I feared that, anyway thank you for your contribution

  18. Pingback: How I learned to stop worrying and love OS X for Java development | David Valeri's Blog

  19. This looks useful. How do I install it?

    I’m new to Mac, trying to add plugins/addons/etc for all the nice little features I’m accustomed to in Linux. But in the Mac world, I hardly know how to tie my shoes or change a light bulb, metaphorically speaking.

Comments are closed.