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 am able to use mdls to show the Uniform Type Identifier (UTI) for an arbitrary file as well as the hierarchy of types that are supersets of a specific UTI.

mac:~ mike$ mdls -name kMDItemContentType -name kMDItemContentTypeTree foo.ksh
kMDItemContentType     = "public.ksh-script"
kMDItemContentTypeTree = (
    "public.ksh-script",
    "public.shell-script",
    "public.script",
    "public.source-code",
    "public.plain-text",
    "public.text",
    "public.data",
    "public.item",
    "public.content"
)
mac:~ mike$ mdls -name kMDItemContentType -name kMDItemContentTypeTree foo.command
kMDItemContentType     = "com.apple.terminal.shell-script"
kMDItemContentTypeTree = (
    "com.apple.terminal.shell-script",
    "public.shell-script",
    "public.script",
    "public.source-code",
    "public.plain-text",
    "public.text",
    "public.data",
    "public.item",
    "public.content"
)

Are there any tools that can show which Apps have registered for a particular UTI other than trial and error?

It's clear from inspection that the foo.command file will be opened by Terminal.app, but it's not at all clear that foo.ksh currently belongs to TextEdit.app.

I'd like to be able to read the Mac OS X Launch Services database directly without actually resorting to using open to see which app is chosen on a per UTI basis. It would be like having --preview --verbose switches to get open to tell me what is would do rather than doing it.

Even better would be a way to list all apps that could open that UTI, even if they are not the preferred app.

To get this secondary information, I have to create or find a file for each type of interest and use Finder to manually show which apps could open that UTI.

enter image description here

I would really like to be able to access this data programatically from the terminal.

share|improve this question
    
The zsh completion seems interesting, but I don't see how to get that as stdout. I'll look into the AppApplications source code and see if the binary works on Lion or I can get it compiled. It's a great pair of leads - thanks! –  bmike Aug 30 '11 at 22:59

2 Answers 2

Andrew Mortensen’s duti is a CLI that will list UTI handlers:

  • -d <uti> lists the default handler;
  • -l <uti> lists all registered handlers.

See the man page for duti.

EDIT: as Lri points out in this answer, duti does not seem to list all possible applications (possibly because it does not take account of UTI inheritance? That would be a matter for further inquiry). His recommended solution, AllApllications would obviously be a better answer.

share|improve this answer
    
It's missing some apps that would be displayed in the open with menu though. –  Lri Oct 12 '11 at 12:50
    
Very odd. Could you tell me which ones it is missing? –  kopischke Oct 12 '11 at 22:18
    
I edited my answer in the other question to include example output from duti. –  Lri Oct 13 '11 at 13:25

You can use this command to examine the launch services database. The -dump option gives you the entire database, then you can pipe this into grep and search for whatever you like.

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump | grep -n7 'your search string'

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.