Find executables associated with Homebrew Formula

As bmike's answer points out, aside from digging through the projects source to determine what executables they install, there's no good way to determine what commands come with a given formula before installing it.

After a formula is installed, running

brew unlink --dry-run formula | grep "$(brew --prefix)/bin"

is a workable option now that --dry-run is available for brew unlink.

Before that was added I wrote an external command called brew executables that still has some benefits over the above (mainly in formatting and handling some links a bit differently). I'll include a simplified (and probably non-working, due to missing some variable assignments) version of it here:

version_in_use=$(echo "$brew_info" | grep "$HOMEBREW_PREFIX.*\*$" | sed -e "s|.*$formula/\([^ ]*\).*|\1|i")

cd "$HOMEBREW_CELLAR/$formula/$version_in_use" 
for dir in `find . -type d -mindepth 1 -maxdepth 1 -name "bin"`; do
    for file in `find "$dir" -type f -o -type l -perm +111`
    do
            filename=$(basename $file)
            echo $filename
    done        
done

In short, it pulls the list of executables out of $(brew --prefix)/$formula/$version_in_use/bin. The version on my GitHub is a bit more fleshed out, including some added ability to identify/indicate when there are commands that link to each other in this bin directory.


I wrote Homebrew-command-not-found to do the reverse thing: get a formula from an executable. There isn’t any easy way to get a formula’s executables as other answers pointed out; so I installed all Homebrew formulae and recorded all executables in one file.

You can find it here. Each formula has its own line with the following format:

<name>: <executable-1> <executable-2> <...>

It’s as easy as grep ^git: executables.txt to get the executables installed by the git formula.

The file is regularly updated and covers 17k+ commands for 5k+ core formulae.