Setting the Default Web Browser from Command Line on Mac
Many advanced Mac users spend a lot of time working from the command line with the Terminal application. The command line offers ways to interact with various settings in MacOS through defaults commands and other tricks, so it’s a reasonable question to wonder if you can set or change the default web browser on a Mac by using the Terminal. Sure, Mac users can change the default web browser at any time by using System Settings on modern MacOS, or System Preferences on older macOS versions, but what if you wish to change the default web browser through the command line on the Mac?
There are two different ways to set the default web browser on a Mac from the command line, and we’ll cover both.
Using the Command Line Tool ‘defaultbrowser’ to Set Default Web Browser on Mac via Terminal
One approach to setting the default browser from the command line on Mac involves an app called ‘defaultbrowser’ that can be installed via Homebrew. Yes that means you will need to install Homebrew first to be able to use this.
brew install defaultbrowser
Once defaultbrowser has been installed, you can use it easily like so:
List all available browsers available to set as the default:
defaultbrowser
Set Safari as the default:
defaultbrowser safari
Set Chrome as the default:
defaultbrowser chrome
Using a Flag for Chromium Browsers to Set as Default on Mac via Terminal
If the web browser is Chrome/Chromium based (ie; Google Chrome, Brave, Microsoft Edge, Epic, etc) then you can use a flag specific to Chromium builds that allows you to set that browser as the default on the Mac, directly from the Terminal.
Setting Chrome as the default browser:
open -a "Google Chrome" --args --make-default-browser
Setting Microsoft Edge as the default browser:
open -a "Microsoft Edge" --args --make-default-browser
Setting Brave as the default browser:
open -a "Brave Browser" --args --make-default-browser
To dissect this command a bit; the open command will open any application specified with the -a flag, and the additional flags are specific to the Chromium browsers. This means you can not use this trick to set Safari as the default browser.
For what it’s worth, you can also use the open command to launch any link in the default browser as set on your Mac, by typing something like the following at the command line:
open https://osxdaily.com
–
Do you know of another method of setting the default web browser from the command line on a Mac? What do you think of these methods? Share your approach, and general thoughts in the comments.
Hi! Is there a way to set an webkit based browser, say Orion, via the Terminal? Thanks in advance.
Yes, you can use the outlined defaultbrowser command to set Orion if you’d like.
defaultbrowser orion
You can also open any application or browser from the Mac command line with:
open (/path/to/application name)
For example, to open Orion from the terminal:
open /System/Applications/Orion.app
Hope that helps!