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've been reading a lot online about custom URL handlers / custom protocol handlers such as:

I get that you can tell the system that a particular program is able to handle a certain scheme / protocol with the Info.plist file:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLName</key>
        <string>Local File</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>local</string>
        </array>
    </dict>
</array>
<key>NSUIElement</key>
<true/>

But if there are multiple applications that are capable of opening the same URL handler, such as mailto: how do you specify which one you want the system to use?

There were some references to utilities like the More Internet preference pane which no longer seems to be available from the author's site. I did find it online by Googling but it seems a bit shaky - like it was written for an older OSX - perhaps Tiger.

I haven't been able to find information on how to set the URL handler for protocols and custom protocols. I'm assuming there is a plist file somewhere that I can edit - or maybe there is a newer, better utility that works well with Mountain Lion?

share|improve this question
up vote 29 down vote accepted

The file you seek is ~/Library/Preferences/com.apple.LaunchServices.plist.

(in OSX 10.11 the main plist is ~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist though the above still exists…)

It holds an array called LSHandlers, and the Dictionary children that define an LSHandlerURLScheme can be modified accordingly with the LSHandlerRole.

Rather than manually editing this file, you can also use RCDefaultApp, which gives you a nice Preference Pane (…doesn't work in OSX 10.11 anymore).

For example, here's SVN and SSH:

… and in RCDefaultApp:

share|improve this answer
12  
4 minutes 19 seconds? Seriously? – Daniel Beck Feb 7 '13 at 21:00
    
Thanks for the fast and detailed answer. Looks good! Question though - I think that I tried RCDefaultApp before and had some issue with it. Has it been working seamlessly for you? – cwd Feb 7 '13 at 21:06
    
@cwd I honestly have to say I don't use it often. More for screenshots for Super User than anything else :) Whenever I need to change file associations I do it through the Get Info… dialog in Finder. I never needed to change protocol and MIME handlers. But it seemed stable enough for me. – slhck Feb 7 '13 at 21:09
    
This seems to be to open a real "app". What if I want to do some custom processing, using a terminal command, etc? – nute Aug 25 '15 at 7:57
    
@nute Just from the top of my head, not sure. Perhaps an app created with Automator that wraps a shell script? – slhck Aug 25 '15 at 11:17

Furthering the previous answer, if you would like to do this on the command line you can use the lstool command, which is the core of RCDefaultApp, found under RCDefaultApp.prefPane/Contents/Resources/lstool.

Its usage is straightforward:

[~]$lstool --help
Usage:

lstool read [<lsscheme> [<type>]]
lstool [-n] write <lsscheme> <type> <app>
lstool [-n] setoption <lsscheme> <type> login|ignorecreator YES|NO
lstool [-n] register {<app>}
lstool [-n] unregister {<path> | <app>}
lstool apps

-n means do not make changes
<lsscheme> is one of: internet, media, url, extension, uti, mime, ostype
<app> is the path to an application or a name to be looked up
share|improve this answer

I actually wrote an application simplifying registration of custom URL protocols, if anyone is interested. It is called LinCastor (http://onflapp.wordpress.com/lincastor/). Handlers can be defined as AppleScript or shell script (which can perl, python or what ever).

share|improve this answer

Listing current LaunchServices URL handler settings on Apple OS X 10.10 (Yosemite):

defaults read com.apple.LaunchServices/com.apple.launchservices.secure
share|improve this answer

Open the file with XCode works quite easy.

Using the build in command plutil as described in the answer on https://discussions.apple.com/thread/5815759 to convert between format xml1 or binary1 works similar.

plutil -convert xml1 /file-i-wish

nano /file-i-wish & save file 

plutil -convert binary1 /file-i-wish

No need for 'alien' tools :-)

share|improve this answer

You can also use duti:

echo $'com.apple.mail mailto\ncom.googlecode.iterm2 x-man-page'>~/.duti;duti ~/.duti
share|improve this answer

I just tried the old More Internet, under El Capitan.

It is funky and the only way it works is via using the up and down arrow keys to select the protocol, and a drag/drop of the APP icon into the window to make a change.

I switched the default from Safari to Chrome, and the change stuck, so it works still.

share|improve this answer

You must log in to answer this question.

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