Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

4 Answers 4

up vote 12 down vote accepted

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

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.

For example, here's SVN and SSH:

… and in RCDefaultApp:

share|improve this answer
    
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

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

You can also use duti:

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.