There is no longer a user friendly command-line entry that returns the default browser name. There are two choices that I am aware of:
# from https://apple.stackexchange.com/questions/313454/applescript-find-the-users-set-default-browser
defaults read ~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure | awk -F'"' '/http;/{print window[(NR)-1]}{window[NR]=$2}'
which returns com.vendor.browsername (e.g. com.apple.safari) for the default browser.
Or you can put the following into a Bash or Zsh script, mark it executable, and run it from the command-line to return just the default browser name:
#!/bin/zsh
# return default browser name that would open the URL
function default_browser () {
osascript <<-AS
use framework "AppKit"
use AppleScript version "2.4"
use scripting additions
property NSWorkspace : a reference to current application's NSWorkspace
property NSURL : a reference to current application's NSURL
set wurl to NSURL's URLWithString:"https://www.apple.com"
set thisBrowser to (NSWorkspace's sharedWorkspace)'s ¬
URLForApplicationToOpenURL:wurl
set appname to (thisBrowser's absoluteString)'s lastPathComponent()'s ¬
stringByDeletingPathExtension() as text
return appname as text
AS
return
}
printf '%s\n' $(default_browser)
exit 0
chmod +x dbrowser.zsh
./dbrowser.zsh
Safari