Set default web browser via command line?

I am trying to figure out how to set the default browser in OS X via the command line. I found this post in the forum , but the solution they are developing is to open a specific URL with a specific application. I am looking for a way to set the default browser system. There, this is a neat GitHub application called Objektiv , which does what I follow, but it is an application. There is a Cocoa method, apparently for setting the default browser to NSWorkSpace.

The preference file com.apple.LaunchServices needs to be changed for this, possibly more.

How to set another default browser via command line?

Thanks for the help.

+7
osx-mountain-lion macos launch-services
source share
2 answers

I know this doesn’t specifically answer your question, but if you need to do this only for Chrome, it has a flag that allows you to set the default browser:

 $ open -a "Google Chrome" --args --make-default-browser 
+2
source share

The only way is to install it in the main settings:

  • From the Apple menu, select System Preferences, then click General.
  • Click the "Default Web Browser" pop-up menu and select a web browser such as Chrome.
0
source share

All Articles