Manage default browser on macOS from the command line.
- macOS 13.0 (Ventura) or later
- Swift 5.9 or later
brew install peter-bread/tap/browserctlPre-built binaries are available via GitHub Releases.
You can also use the provided installation script:
curl -fsSL https://raw.githubusercontent.com/peter-bread/browserctl/refs/heads/main/scripts/install.sh | bashThis will install the browserctl binary and manpage to the ~/.local prefix.
Optionally, set the PREFIX environment variable:
curl -fsSL https://raw.githubusercontent.com/peter-bread/browserctl/refs/heads/main/scripts/install.sh | PREFIX=/usr/local bashThis may require updating MANPATH.
Build and install browserctl.
By default, the executable is installed to the prefix ~/.local, meaning the
path to the executable is ~/.local/bin/browserctl.
The install target will build and install both the binary and the manpage:
git clone https://github.com/peter-bread/browserctl
cd browserctl
make installTo install to a different location, specify a prefix (you may need sudo):
sudo make install PREFIX=/usr/localTip
For more information, be sure to use browserctl help and browserctl help <subcommand>.
(Or browserctl -h and browserctl <subcommand> -h)
browserctl getbrowserctl listFor each of the above, you can use --name-only or --id-only to filter the
output data.
browserctl set <query>The query must be an exact, case-insenstive match against one of, in order:
- bundle ID
- bundle display name
- bundle name
For example, the following are equivalent:
browserctl set chrome # name
browserctl set 'GooGLe ChrOme' # display name
browserctl set com.google.Chrome # idCurrently, there is no support for fuzzy matching, suggestions or multiple matches.
# launch default browser
browserctl launch
# launch specified browser
browserctl launch <name|id>
# launch default browser and open url
browserctl launch --url <url>
# launch specified browser and open url
browserctl launch <name|id> --url <url>You can generate shell completion with:
browserctl --generate-completion-script <shell>where shell is one of bash, zsh or fish.
This is especially useful for the browserctl set command as it provides names and identifiers.