Skip to content

Instantly share code, notes, and snippets.

@vitalymak
Created January 24, 2017 09:46
Show Gist options
  • Save vitalymak/592d0ffa3f781038ca39745dbbe64801 to your computer and use it in GitHub Desktop.
Save vitalymak/592d0ffa3f781038ca39745dbbe64801 to your computer and use it in GitHub Desktop.
dir_sizes macOS using coreutils
# 1) first install coreutils
brew install coreutils
# 2) but!!! let them do not replace internal macOS utils by modifying PATH check your ~/.bash_profile
# that you include brew sbin & coreutils AFTER internal /usr/bin etc.
export PATH=$PATH:/usr/local/sbin # but NOT!!!: export PATH=/usr/local/sbin:$PATH
export PATH=$PATH:/usr/local/opt/coreutils/libexec/gnubin
# 3) add it to your ~/.bash_profile
function dir_sizes {
find . -maxdepth 1 -type d -mindepth 1 -exec du -hs {} \; | /usr/local/opt/coreutils/libexec/gnubin/sort -rh
}
# sample output
# vit:node_modules vitaly$ dir_sizes
# 73M ./intl
# 44M ./phantomjs-prebuilt
# 21M ./typescript
# 21M ./npm
# 19M ./libxmljs
# 13M ./babel-jscs
# 10.0M ./cordova-app-hello-world
# 7.5M ./jscs
# 7.4M ./fsevents
# 6.6M ./core-js
# 5.7M ./spdx-license-list
# 5.4M ./webpack-dashboard
# 5.0M ./istanbul-threshold-checker
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment