Basically what I'd like to know is how can I setup a shell script (or an Applescript or Automator wrapper for a shell script) as a protocol handler for a custom URI (so clicking them will trigger my script) with the URI passed in as an argument?

For example, if my URI looked something like:


How could I setup a shell script on OS X to be triggered any time a URI with protocol "foo" is clicked, and to receive the entire URI as an argument I can then process? I already have the script for processing done, just don't know how to get it triggered in the first place :)

1 Answer 1


This technique works for me.

Here are some other relevant answers from around Stack Exchange:

A couple of relevant utilities are RCDefaultApp and duti.

  • You're right the custom URL handlers link was what I needed. For those interested you can do this easily be creating an Applescript applet (save script as Application) then edit the info.plist file to add the CFBundleURLTypes key which lets you specify URL types and their protocols for the Launch Services database to invoke. When editing the application, it's better to open its contents and find the script and edit it directly, otherwise you will lose any custom info.plist, icon etc.
    – Haravikk
    Aug 1, 2013 at 20:33

You must log in to answer this question.

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