Is it possible to query the launch services database for applications that will open an arbitrary file or UTI...












10















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
















10















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














10












10








10


8






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
















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.







macos osx-lion






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 15 '11 at 23:49







bmike

















asked Aug 15 '11 at 21:02









bmikebmike

2,14321742




2,14321742













  • 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



















  • 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

















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





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






active

oldest

votes


















6














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













  • While duti is nicely written, it now uses deprecated APIs. I recommend to take a look at developer.apple.com/library/prerelease/mac/documentation/Carbon/…

    – Mugen
    Aug 27 '15 at 6:28











  • OK - installing this by homebrew knocks a home run. Thanks so much!

    – bmike
    Sep 22 '15 at 17:16



















10














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
























  • I'll probably need to ask a follow on question how to process this dump to spit out the app bundle or the location of the specific mdimporter file that parses a specific kMDItemContentType - but this has helped greatly. Thank you

    – bmike
    Sep 22 '15 at 17:14














Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f323599%2fis-it-possible-to-query-the-launch-services-database-for-applications-that-will%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









6














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













  • While duti is nicely written, it now uses deprecated APIs. I recommend to take a look at developer.apple.com/library/prerelease/mac/documentation/Carbon/…

    – Mugen
    Aug 27 '15 at 6:28











  • OK - installing this by homebrew knocks a home run. Thanks so much!

    – bmike
    Sep 22 '15 at 17:16
















6














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













  • While duti is nicely written, it now uses deprecated APIs. I recommend to take a look at developer.apple.com/library/prerelease/mac/documentation/Carbon/…

    – Mugen
    Aug 27 '15 at 6:28











  • OK - installing this by homebrew knocks a home run. Thanks so much!

    – bmike
    Sep 22 '15 at 17:16














6












6








6







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















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














share|improve this answer



share|improve this answer








edited Mar 1 at 7:05

























answered Oct 12 '11 at 8:20









kopischkekopischke

2,0211527




2,0211527













  • 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













  • While duti is nicely written, it now uses deprecated APIs. I recommend to take a look at developer.apple.com/library/prerelease/mac/documentation/Carbon/…

    – Mugen
    Aug 27 '15 at 6:28











  • OK - installing this by homebrew knocks a home run. Thanks so much!

    – bmike
    Sep 22 '15 at 17:16



















  • 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













  • While duti is nicely written, it now uses deprecated APIs. I recommend to take a look at developer.apple.com/library/prerelease/mac/documentation/Carbon/…

    – Mugen
    Aug 27 '15 at 6:28











  • OK - installing this by homebrew knocks a home run. Thanks so much!

    – bmike
    Sep 22 '15 at 17:16

















It's missing some apps that would be displayed in the open with menu though.

– Lri
Oct 12 '11 at 12:50





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





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







I edited my answer in the other question to include example output from duti.

– Lri
Oct 13 '11 at 13:25















While duti is nicely written, it now uses deprecated APIs. I recommend to take a look at developer.apple.com/library/prerelease/mac/documentation/Carbon/…

– Mugen
Aug 27 '15 at 6:28





While duti is nicely written, it now uses deprecated APIs. I recommend to take a look at developer.apple.com/library/prerelease/mac/documentation/Carbon/…

– Mugen
Aug 27 '15 at 6:28













OK - installing this by homebrew knocks a home run. Thanks so much!

– bmike
Sep 22 '15 at 17:16





OK - installing this by homebrew knocks a home run. Thanks so much!

– bmike
Sep 22 '15 at 17:16













10














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
























  • I'll probably need to ask a follow on question how to process this dump to spit out the app bundle or the location of the specific mdimporter file that parses a specific kMDItemContentType - but this has helped greatly. Thank you

    – bmike
    Sep 22 '15 at 17:14


















10














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
























  • I'll probably need to ask a follow on question how to process this dump to spit out the app bundle or the location of the specific mdimporter file that parses a specific kMDItemContentType - but this has helped greatly. Thank you

    – bmike
    Sep 22 '15 at 17:14
















10












10








10







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













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












share|improve this answer



share|improve this answer










answered Apr 17 '12 at 21:13









ChrisChris

10113




10113













  • I'll probably need to ask a follow on question how to process this dump to spit out the app bundle or the location of the specific mdimporter file that parses a specific kMDItemContentType - but this has helped greatly. Thank you

    – bmike
    Sep 22 '15 at 17:14





















  • I'll probably need to ask a follow on question how to process this dump to spit out the app bundle or the location of the specific mdimporter file that parses a specific kMDItemContentType - but this has helped greatly. Thank you

    – bmike
    Sep 22 '15 at 17:14



















I'll probably need to ask a follow on question how to process this dump to spit out the app bundle or the location of the specific mdimporter file that parses a specific kMDItemContentType - but this has helped greatly. Thank you

– bmike
Sep 22 '15 at 17:14







I'll probably need to ask a follow on question how to process this dump to spit out the app bundle or the location of the specific mdimporter file that parses a specific kMDItemContentType - but this has helped greatly. Thank you

– bmike
Sep 22 '15 at 17:14




















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f323599%2fis-it-possible-to-query-the-launch-services-database-for-applications-that-will%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Index of /

Tribalistas

Listed building