Q:

Homebrew: List only installed top level formulas

I'm looking for a way to show only the formulas I installed without the installed dependencies. 
I want to have a list of all the programs I actually installed, without all noise of the dependencies. 
I do know about brew list which lists all installed formulas. 
I also know that brew graph gives me a dependency graph in the graphviz
Or in other words: I want to have the minimal set of formulas to reinstall my system. 

A:

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

A:

$ 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? 

A:

this shows installed formulas as a tree. 
brew deps --installed --tree

