Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to OS X to intelligently open git URLs by first trying to open their repo page on GitHub, and then falling back to something like

I found this question extremely helpful, and I created an Automator app to wrap a bash script (which does all of the intelligent stuff), and used RCDefaultApp to set OS X to use my automator app to open git:// URLs.

This didn't work, so I tried some debugging. I set my bash script to output its arguments to /tmp/output.txt, and it turns out that the script isn't getting any command line arguments. If I set OS X to use this same automator app as the default app for *.txt files, the bash script correctly gets the path of the file as the first argument, but it doesn't work with URLs. Any idea how to get this to work?

Also, I'm running 10.7.

Edit: Here's a snapshot of the Automator app: Automator app

And here's the text of that simple bash script (not what I would actually use to open the git:// URLs, but it demonstrates the lack of arguments:

rm -f /tmp/output.txt
echo $0 >> /tmp/output.txt
echo $* >> /tmp/output.txt

And the only output I get in /tmp/output.txt is:

share|improve this question
Might be helpful to post your script and/or Automator app here for others to try. – slhck Jan 2 '12 at 9:35
up vote 4 down vote accepted

It doesn't work like that, because OS X doesn't treat files, folders, and URLs, which are just command line arguments to the associated programs on other systems, like other platforms. Automator programs really only can handle files and folders.

You need to create an AppleScript based application, which responds to open location.

Open AppleScript Editor, and paste the following code (changing the script of course):

on open location myURL
    do shell script "echo " & myURL & " > /Users/danielbeck/test"
end open location

Save as application. Then select the application bundle you just created, right-click, Show Package Contents, and edit Contents/Info.plist using a text editor (after converting to XML using plutil on the command line, if it's binary), or the default editor which is part of Apple's Developer Tools.

Add the following to its top-level structure (the screenshot is how it looks like in current Xcode, the XML is what you'd add in a text editor):

enter image description here

        <string>AppleScript Testing URL</string>

That will associate openme:// URLs with that application. Save, move the program to a different folder and back to update Launch Services, and test it by typing an openme:// URL into a web browser's address bar:

enter image description here

You'll want to replace openme by git and the echo call by your shell script, of course.

share|improve this answer
So does that application automatically register for the git protocol or do you have to change the Launch Services association? As for updating Launch Services, shouldn't it be enough to touch the .app? – slhck Jan 2 '12 at 11:02
@slhck It will automatically register the git:// scheme (like I did for the openme:// scheme), but use of RCDefaultApp or something similar might be necessary to grab it from a different Git client (similar to associating a file type with a viewer, just without UI). touch works fine for updating Launch Services, I usually just don't have a Terminal window open at that point and drag&drop in Finder, Cmd-Z to undo, is usually faster. – Daniel Beck Jan 2 '12 at 11:05
@slhck I messed up my user profile so much working out all these SU answers it's not even funny, so I try to not use "productive" file extensions, URL schemes, etc. whenever possible. You don't even want to see my services folder :-) – Daniel Beck Jan 2 '12 at 11:08
Regarding the Terminal window: If you don't know it yet, you could try DTerm. And I saw your services context menu in a recent screenshot – I was like, … what? :) – slhck Jan 2 '12 at 11:08
@slhck Thanks for the link! Regarding the services menu, that one was already filtered, actually. Only about half the Files and Folders services are checked. I have 64 items in ~/Library/Services, a folder that does not exist by default ;-) – Daniel Beck Jan 2 '12 at 11:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .