Created
December 28, 2016 01:09
-
-
Save rdmarsh/9cedd379fa2573b4a4519bb7497132d0 to your computer and use it in GitHub Desktop.
produces a dot graph for homebrew dependencies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#produces a dot graph for homebrew dependencies | |
#run using `./brew-tree.sh | dot -Tpdf -o brew-tree.pdf` | |
set -e #exit immediately if a simple command exits with a non-zero status | |
set -u #treat unset variables as an error when performing parameter expansion | |
set -o pipefail #exit status of last non-zero exit code is returned | |
echo "digraph brew {" | |
echo " node [shape=Mrecord, fontname=monospace]" | |
echo " rankdir=LR" | |
echo " overlap=false" | |
echo " splines=true" | |
echo " layout=dot" | |
echo | |
for formula in $(/usr/local/bin/brew list) ; do | |
echo " \"${formula}\"" | |
#clean names | |
for deps in $(/usr/local/bin/brew deps "${formula}") ; do | |
echo " \"${deps}\" [style=filled,fillcolor=\"/accent3/2\"]" | |
echo " \"${formula}\" -> \"${deps}\"" | |
done | |
done | |
#color leaves | |
for formula in $(/usr/local/bin/brew leaves); do | |
echo " \"${formula}\" [style=filled,fillcolor=\"/accent3/1\"]" | |
done | |
echo "}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment