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

Is it a fallacy if someone claims they need an explanation for every word of your argument to the point where they don't understand common terms?

How much mayhem could I cause as a sentient fish?

How to avoid being sexist when trying to employ someone to function in a very sexist environment?

How can animals be objects of ethics without being subjects as well?

How can I get my players to come to the game session after agreeing to a date?

Does paint affect EMI ability of enclosure?

A starship is travelling at 0.9c and collides with a small rock. Will it leave a clean hole through, or will more happen?

How should I handle players who ignore the session zero agreement?

Avoiding morning and evening handshakes

Word or phrase for showing great skill at something WITHOUT formal training in it

How would an AI self awareness kill switch work?

Pronunciation of umlaut vowels in the history of German

Why are the books in the Game of Thrones citadel library shelved spine inwards?

Roman Numerals equation 1

Why isn't there a non-conducting core wire for high-frequency coil applications

One Half of Ten; A Riddle

Early credit roll before the end of the film

Am I a Rude Number?

Using only 1s, make 29 with the minimum number of digits

Table formatting top left corner caption

Can I write a book of my D&D game?

How do Chazal know that the descendants of a Mamzer may never marry into the general populace?

What's a good word to describe a public place that looks like it wouldn't be rough?

What is the lore-based reason that the Spectator has the Create Food and Water trait, instead of simply not requiring food and water?



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


Access Finder's “Open With” menu from the commandline (for tab completion)Command to list all apps capable of opening a given extensionOS X: Terminal command to check a file's default applicationCan I change the order of non-apple icons on the menu bar of my MacBook?OS X “service” for running JavaScript bookmarklets in any app?How do open a HTML file as text on OS X?Create bash script to open URL in Mac OS XHow to Re-install an App that Shows up in the Appstore as 'Update' Instead of 'Buy App'How to replicate the “Move to Dropbox” Mac OS X Finder context menu item for other apps?OS X command to make current terminal window full screenMac Command Line Open PDF to Specific PageRun a Python script with filename arguments as a MacOS Folder actionMacOS 10.13.3 rsync and terminal: filenames with scandic letters













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


















5














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









5














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
















5














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














5












5








5







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 1 min ago

























answered Oct 12 '11 at 8:20









kopischkekopischke

2,0011427




2,0011427













  • 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

Why not use the yoke to control yaw, as well as pitch and roll? Announcing the arrival of...

Couldn't open a raw socket. Error: Permission denied (13) (nmap)Is it possible to run networking commands...

VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...