Last active
August 17, 2025 22:27
-
Star
(121)
You must be signed in to star a gist -
Fork
(20)
You must be signed in to fork a gist
-
-
Save eguven/23d8c9fc78856bd20f65f8bcf03e691b to your computer and use it in GitHub Desktop.
List all packages installed using Homebrew and their sizes
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
| # this original one uses values returned from 'brew info' | |
| brew list --formula | xargs -n1 -P8 -I {} \ | |
| sh -c "brew info {} | egrep '[0-9]* files, ' | sed 's/^.*[0-9]* files, \(.*\)).*$/{} \1/'" | \ | |
| sort -h -r -k2 - | column -t | |
| # faster alternative using 'du' | |
| du -sch $(brew --cellar)/*/* | sed "s|$(brew --cellar)/\([^/]*\)/.*|\1|" | sort -k1h |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TLDR; the
du-wildcardversion is the simplest and fastest.Summary of pipelines and timings
brew list | parallel "brew info {}"brew info $(brew list)brew list | xargs brew --cellar | xargs du -schbrew_list_with_versions | xargs du -schdu -sch $(brew --cellar)/*/*Three run average, for
parallelandlinearLet's go over the existing solutions from above.
First, lets wrap our
brew info ... | sed ...pipeline into a function.Also note, that all lsited functions here are
bashandzshcompatible.And, then, lets wrap the sizing into a parallel pipeline function
However, parallel fs sizing operations won't improve performance. Here's the timing for the
parallelversion.Since
brew infoaccepts multiple formulas, we can do a linear, non-parallel version.You could just pipe everything to
duand get the sizes per formula, but not the sizes per formula per version.brew list --formula --versionsdoes produce all the versions for each formula.You could then fold the formulas together with the versions, like this:
You could just use 'du' on
Cellar/some_formula/some.versionlike this: