MacOS – Terminal command to list application defaults

applicationscommand linedefaultsmacos

I'm new to Mac from the Linux world, and I am looking for a command or file providing a list to default user applications associated with certain filetypes. For example, on Linux:

$ cat /usr/share/applications/defaults.list

provides the application names and priority hierarchies on Linux. I've tried something similar using defaults on the Mac, but I can't seem to find what I'm looking for.

$ defaults read | grep pdf
  name = "1309.0238.pdf";
  name = "1309.0238.pdf";

Does the Mac operating system have a simple, command-line function or accessible file to find the default applications?

Best Answer

Not easily. You can use the well-hidden lsregister command to dump the contents of the Launch Services database, which is what controls which file types open with which applications:

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump

but its output isn't well documented -- there's some info here, but it's over 10 years old so it's probably at least partially obsolete. A bit of Googling turns up some AppleScripts for further parsing, that you might be able to adopt: