Homebrew command-line to display a formula’s homepage

command linehomebrew

I can open the homepage for a Homebrew formula by running the following command-line:

brew home <formula>

and for a Homebrew Cask by running the following command-line:

brew cask home <cask>

However, running the above command-lines immediately open the homepage in the default Web-browser.

Is there a way (preferably via command-line) to only display the homepage for a formula or cask without opening it in a Web-browser?

Additionally, is there a way to configure the command-line such so as to open the link in a specific Web-browser?

Best Answer

The homepage URL is a part of the output of brew info FORMULA, so you can run:

brew info FORMULA | grep -E '^https?:'

to extract just the link to the homepage. This also allows to run:

open -a Firefox.app "$(brew info FORMULA | grep -E '^https?:')"

to open the link in Firefox.app.

The respective command-lines for Homebrew Cask are:

brew cask info CASK | grep -E '^https?:'

and

open -a Firefox.app "$(brew cask info CASK | grep -E '^https?:')"