Terminal command to list application defaults?
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:
- https://stackoverflow.com/a/3452435/476909
- https://macosx.com/threads/howto-list-your-installed-applications.26204/
There is a third-party github project called SwiftDefaultApps, which provides a command line tool and a MacOS Preference pane for listing and setting the URIs, UTIs and their app handlers.
Utility to retrieve and manipulate default applications in macOS.
Available commands:
- getHandler Returns the default application registered for the URI Scheme or <subtype> you specify.
- getApps Returns a list of all registered applications.
- getSchemes Returns a list of all known URI schemes, accompanied by their default handler.
- getUTIs Returns a list of all known UTIs, and their default handler.
- setHandler Sets <application> as the default handler for a given <type>/<subtype> combination.
- help Prints this help information
- version Prints the current version of this app
.
(It's a replacement for the long-standing RCDefaultsApp pane, which completely stopped working in Catalina.)