how to change default browser via terminal/update-alternatives?

My question is not specific to just the web browser but other things like mail/calender/opening PDF/zip/other file extensions.

So how can I change default browser using terminal? I've tried these 2 commands and

update-alternatives --set gnome-www-browser /usr/bin/google-chrome-stable
update-alternatives --set x-www-browser /usr/bin/google-chrome-stable

According to

update-alternatives --get-selections | grep browser

Google Chrome is supposedly my default browser.

enter image description here

But when I go to System Settings, Firefox is listed as the default.

enter image description here

When I double-click a simple HTML I created using vi, the file opens up in Firefox. I restarted Ubuntu but I get the same behavior.

so what am I doing wrong? Thank you.

edit1: I've also tried update-alternatives --config gnome-www-browser/x-ww-browser. no effect

enter image description here

edit2: According to update-alternatives, firefox is not assigned to anything!

enter image description here


That settings cannot be changed by update-alternatives. It's controlled by xdg-settings. You can use this command to change the default from command line

xdg-settings set default-web-browser google-chrome.desktop