Open sindresorhus opened 11 years ago
Chrome has command line argument for this: --make-default-browser
(example). I’m not sure it’s possible for other browsers.
Neat, but that doesn't solve it for wanting Chrome Canary, Firefox or any other browser as default.
@sapegin: Thanks for the info! I didn’t know about that Chrome flag.
I did some digging, and it seems defaults read com.apple.LaunchServices LSHandlers
returns an array containing entries such as the following (assuming Google Chrome Canary is the default browser):
{
LSHandlerContentType = "public.html";
LSHandlerRoleAll = "com.google.chrome.canary";
},
{
LSHandlerContentType = "public.xhtml";
LSHandlerRoleAll = "com.google.chrome.canary";
},
{
LSHandlerRoleAll = "com.google.chrome.canary";
LSHandlerURLScheme = http;
},
{
LSHandlerRoleAll = "com.google.chrome.canary";
LSHandlerURLScheme = https;
}
As there are lots of other entries though, it’s kinda tricky to add/modify these values cleanly using the defaults
command. However, this could easily be done using duti
(ref. #54) using a settings file like this:
com.google.chrome.canary public.html all
com.google.chrome.canary public.xhtml all
com.google.chrome.canary http
com.google.chrome.canary https
(Untested, but it should work.)
To set another browser as the default, simply look up its bundle ID and use it instead of com.google.chrome.canary
.
@sindresorhus You can't make Chrome Canary your default browser. Just a heads up.
@kevinSuttle :( I don't understand the restriction...
@sindresorhus It's apparently so it can be ran side by side with the stable builds.
http://www.google.com/intl/en/chrome/browser/canary.html (Bottom right: Side by Side Install).
@kevinSuttle you can actually set Chrome Canary as default, just not programatically.
Go into Safari and set it there. Works great for me. But would be awesome to have this preconfigured in my dotfiles.
@sindresorhus Hm. I did not know that. Thanks! :thumbsup:
I just wrote the following to do this in Python: https://gist.github.com/miketaylr/5969656
@miketaylr Awesome! Nice work.
Is it possible to programmatically set the default browser?
Either through a Plist or AppleScript or something.
Would be useful to have in .osx