How to Quickly Set Default Apps for File Types in macOS
The Problem
I am working on a script that can configure a fresh macOS installation. One of the problems is to change what application is used to open files in Finder. You can use Finder UI Get Info > Open with: -> Change All ...
, but it is cumbersome, and you also need a file with a specific extension to set it.
The solution
There is a better way. You can use utility called duti that can set default applications for various document types on macOS.
First you need to get bundle id for the app you want to open files with:
Now install duti
. I recommend installing with homebrew.
Now you can easily set an application to open a specific file given its UTI (e.g., public.html), extension or MIME type: