Skip to content

About

Manage default browser on macOS 13 or later

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Browserctl

Manage default browser on macOS from the command line.

CI

Requirements

  • macOS 13.0 (Ventura) or later

Build-only

  • Swift 5.9 or later

Install

Homebrew

brew install peter-bread/tap/browserctl

GitHub Releases

Pre-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 | bash

This 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 bash

This may require updating MANPATH.

Build from Source

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 install

To install to a different location, specify a prefix (you may need sudo):

sudo make install PREFIX=/usr/local

Usage

Tip

For more information, be sure to use browserctl help and browserctl help <subcommand>.

(Or browserctl -h and browserctl <subcommand> -h)

Get current default browser

browserctl get

List available browsers

browserctl list

For each of the above, you can use --name-only or --id-only to filter the output data.

Set default browser

browserctl set <query>

The query must be an exact, case-insenstive match against one of, in order:

  1. bundle ID
  2. bundle display name
  3. bundle name

For example, the following are equivalent:

browserctl set chrome             # name
browserctl set 'GooGLe ChrOme'    # display name
browserctl set com.google.Chrome  # id

Currently, there is no support for fuzzy matching, suggestions or multiple matches.

Launch browser

# 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>

Shell Completion

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.

Acknowledgements

About

Manage default browser on macOS 13 or later

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages