LinuxCommandLibrary

sensible-browser

Open a URL in the user's preferred browser

TLDR

Open a new window of the default browser

$ sensible-browser
copy

Open a URL in the default browser
$ sensible-browser [url]
copy

SYNOPSIS

sensible-browser [URL]

PARAMETERS

URL
    The URL to be opened in the browser. This is a mandatory parameter.

DESCRIPTION

The sensible-browser command is a utility designed to open a URL in the user's preferred web browser. It intelligently attempts to determine the most suitable browser available on the system, respecting environment variables like BROWSER and configuration files that define browser preferences. If no specific browser is indicated, it defaults to a browser deemed 'sensible' for the current environment, typically based on system configuration or common desktop environments. It aims to provide a consistent user experience across different Linux distributions and desktop setups, preventing applications or scripts from hardcoding specific browser names and potentially failing on systems where those browsers are not installed. It simplifies opening web links from the command line or within scripts, ensuring the URL is handled by the user's chosen browser.

The tool typically iterates through an ordered list of browsers, testing each one for availability. The exact list of browsers and their order of preference can vary based on the distribution and system configuration. Configuration options such as update-alternatives may influence which browser is ultimately selected. Therefore, while simple to use, the underlying logic for browser selection can be quite complex, aiming for broad compatibility and respect for user settings.

BROWSER SELECTION LOGIC

sensible-browser typically relies on a series of checks to determine the appropriate browser. This may involve checking the BROWSER environment variable, looking at the output of update-alternatives (on Debian-based systems), or consulting a predefined list of known browsers. The exact order and methods used to select a browser may vary between distributions.

ERROR HANDLING

If sensible-browser cannot find a suitable browser, it will typically exit with an error message. This error message may indicate that no browser is installed or that no browser could be detected based on the current configuration.

SEE ALSO

xdg-open(1), open(1)

Copied to clipboard