Macos – How to change default app for all files of particular file type through terminal in OS X

file associationmacos

How can I change the default app for all files of a particular file type through the Terminal in OS X?

Best Answer

I have a simpler way. You'll want Homebrew if you don't already have it:

/usr/bin/ruby -e "$(curl -fsSL"

Install duti:

brew install duti

Now you need to find the id of the app you want to use, and assign it to the extension you want to use it for. In this example, I already use Brackets for *.sh and I want to also use it for *.md files instead of xcode.

Get the default app id for .sh files:

duti -x sh


The last line is the id.

Use this app id for all .md files:

duti -s io.brackets.appshell .md all