6

Suppose I have added a new tap to Brew using brew tap ....

I've tried looking into brew search, brew tap, and brew tap-info, but none of these subcommand present any suitable options.

How can I list all formulae available within that tap?

1
  • @nohillside - I've updated the question.
    – Shuzheng
    Commented Jun 4, 2020 at 12:00

1 Answer 1

10

From this Stack Overflow article:

List of formulae in a tap can be found by running brew tap-info $TAP --json

To turn this into a proper readable format we can run brew tap-info $TAP --json | jq -r '.[]|(.cask_tokens[])'

Example: To find all formulae in homebrew/cask-fonts we can do: brew tap-info homebrew/cask-fonts --json | jq -r '.[]|(.cask_tokens[])'

Break down of the command:

  1. brew tap-info homebrew/cask-fonts --json lists JSON info of the taps and some other stuff (output)
  2. jq -r '.[] removes the outside square bracket (output)
  3. |(.cask_tokens[])' gets the JSON value of the key cask_tokens

TL;DR: Running brew tap-info <tap-here> --json | jq -r '.[]|(.cask_tokens[])' will give you the formulae from that tap.

Note If this fails to list all try running brew tap-info <tap-here> --json | jq -r '.[]|(.formula_names[],.cask_tokens[])'

3
  • Why is .formula_names[] necessary? May a tap contain both formulae and casks?
    – Shuzheng
    Commented Jun 4, 2020 at 12:34
  • @Shuzheng Hmm thats interesting. For me this change of removing .formula_names[] made no difference to the output. From this paste we can see that there is a field with the key "formula_names". I am not sure if it is required to run with .formula_names[], but since the field is there in the JSON output I'm leaving it there for now.
    – Roxiun
    Commented Jun 4, 2020 at 12:52
  • @Shuzheng Yes, "Casks can be included in taps with formulae, or in a tap with just casks." See docs.brew.sh/How-to-Create-and-Maintain-a-Tap#casks. Moreover, a tap can also provide external commands, see docs.brew.sh/How-to-Create-and-Maintain-a-Tap#external-commands. Commented Jul 31 at 15:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .