Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 use the command line to find out which application opens http and https links. I need to do this in a script. I can see the answer by executing 'defaults read' but I don't want to parse that dictionary myself.

share|improve this question

Apple Script has built-in capabilities to parse property list files. StefanK on provides a snippet which already helped me some time ago. You can save and execute it easily as a script, I stored it in my user bin directory (which I added to my $PATH):


tell (system attribute "sysv") to set MacOS_version to it mod 4096 div 16
if MacOS_version is 5 then
    set {a1, a2} to {1, 2}
    set {a1, a2} to {2, 1}
end if
set pListpath to (path to preferences as Unicode text) & ""
tell application "System Events"
    repeat with i in property list items of property list item 1 of contents of property list file pListpath
        if value of property list item a2 of i is "http" then
            return value of property list item a1 of i
        end if
    end repeat
    return ""
end tell
share|improve this answer

Other options:

VERSIONER_PERL_PREFER_32_BIT=1 perl -MMac::InternetConfig -le 'print +(GetICHelper "http")[1]'

tell application "System Events"
        value of property list item "LSHandlerRoleAll" of (property list item 1 of property list item "LSHandlers" of property list file ((path to preferences as text) & "") where value of property list items contains "http")
    on error
    end try
end tell

$ DefaultApplication -url http:
share|improve this answer

Your Answer


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.