Skip to content

Instantly share code, notes, and snippets.

@eguven
Last active February 7, 2024 06:16
Star You must be signed in to star a gist
Save eguven/23d8c9fc78856bd20f65f8bcf03e691b to your computer and use it in GitHub Desktop.
List all packages installed using Homebrew and their sizes
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
@georgio
Copy link

georgio commented Feb 18, 2021

This is identical to what @bkeys818 posted except it's compatible with the fish shell

brew install parallel; parallel --citation   #Skip this step if parallel is already installed
brew list --formula | parallel "brew info {} | egrep '[0-9]* files, ' | sed 's/^.*[0-9]* files, \(.*\)).*(/{}) \1/'" | sort -k2 -hr

@vogler
Copy link

vogler commented Nov 7, 2023

Alternative: brew install ncdu && ncdu /opt/homebrew/Cellar

@manan-gup
Copy link

Works on fish shell without parallel:

brew list --formula | xargs -P8 -I {} sh -c "brew info {} | grep -E '\([0-9]+ files'" \
| awk -F '[/(),]' '{print $6 ", " $8 ", " $9}' | sort -t "," -rh -k3

and gives output in a comma-separated format which can be simply changed in the awk command:

exiftool, 603 files,  25.3MB
micro, 7 files,  11.4MB
tealdeer, 12 files,  5.4MB
bat, 14 files,  4.6MB
eza, 14 files,  1.1MB

@adk-anw
Copy link

adk-anw commented Jan 15, 2024

Worked for me too! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment