Homebrew: List only installed top level formulas

Use brew leaves: show installed formulae that are not dependencies of another installed formula.


$ brew deps --installed
tmux: pkg-config libevent
q:
gdbm:
libxml2:
asciidoc: docbook
libevent:
pkg-config:
pcre:
docbook:
zsh: gdbm pcre
readline:
emacs: pkg-config

This seems to give us a list of all installed formulae including their dependencies. We can build a list of all formulae and a list of all dependencies and subtract the dependencies from the list of formulae, this should give us a list of formulae which are not dependencies of other formulae:

$ cat brew-root-formulae.sh
#!/bin/sh

brew deps --installed | \
    awk -F'[: ]+' \
    '{
        packages[$1]++
        for (i = 2; i <= NF; i++)
            dependencies[$i]++
    }
    END {
        for (package in packages)
            if (!(package in dependencies))
                print package
    }'

.

$ ./brew-root-formulae.sh
zsh
asciidoc
libxml2
readline
tmux
q
emacs

Is this the output you are after?


this shows installed formulas as a tree.

brew deps --installed --tree

only show dependencies one level down

brew deps --1 --installed --tree

only show installed php formula

brew deps --installed --tree php 

opens a website for visualization

brew deps --installed --graph php

Tags:

Homebrew