Apple tends to design its applications for the average users making life needlessly hard for power users. Sometimes you just want to change default applications via the command-line instead of having to sift through various sub menus of the system settings.
Installation
This can easily be achieved with SwiftDefaultApps. Simply install it via brew:
brew install swiftdefaultappsprefpane
In case you get the following error:
“swda” cannot be opened because the developer cannot be verified.
macOS cannot verify that this app is free from malware.
Move to Bin
/Cancel
The only solution that worked for me is to delete the com.apple.quarantine
extended attribute from the binary. This metadata attribute is set on files by applications like browsers that download files over the network.
xattr -d com.apple.quarantine "$(which swda)"
Note: this generally also works for apps in which case you also need to specify -r
to apply the change recursively, e.g.:
xattr -r -d com.apple.quarantine /Applications/ChatGPT.app
Examples
# Get configured default internet browser
▶ swda getHandler --internet
/Applications/Google Chrome.app
# Configure default internet browser (by path or ID)
## Edge
▶ swda setHandler --app /Applications/Microsoft\ Edge.app --internet
▶ swda setHandler --app com.microsoft.edgemac --internet
## Chrome
▶ swda setHandler --app /Applications/Google\ Chrome.app --internet
▶ swda setHandler --app com.google.Chrome --internet
## Chrome
▶ swda setHandler --app /Applications/Safari.app --internet
▶ swda setHandler --app com.apple.Safari --internet
## Firefox
▶ swda setHandler --app /Applications/Firefox.app --internet
▶ swda setHandler --app org.mozilla.firefox --internet
# Change the tel handler (default: /System/Applications/FaceTime.app)
▶ swda setHandler --URL tel --app /Applications/RingCentral.app