Say I have some files
simple_doc.txt
document.pdf
website.html
The .txt
file opens with textEdit by default, the .pdf
opens with Adobe Reader and the .html
file will open in Google Chrome.
How can I find out this information from the command line? In particular, how can I find the icon of the default application for each of these files from the command line alone.
Thank you!
Best Answer
Background
There's a couple of tools you can use to analyze this situation.
lsregister
defaults read
NOTE:
lsregister
is located here:Navigating lsregister
You can use this command to navigate through the output from
lsregister
:The structure is a little difficult to discern but you can look for strings such as
.txt
and take note of the lines occurring before it.To help us navigate this output, we can look in the Finder GUI for a type of file that we're interested in, for example a
For example.txt
file. Select it and then open up the info dialog about this particular file (⌘ + I).With the details such as the "Kind: Plain Text Document" and what application it's associated with to open it, "TextEdit" we can then look through
lsregister
output and see if we cannot correlate things a bit.For starters lets look for that "Kind: Plain Text Document".
Above we can see that the icon for the default is this:
Contents/Resources/document.icns
.References
defaults
CLI