Summary
Homebrew で使われていない formula を整理したい。依存しているパッケージ数を表示
brew uses --installed PACKAGE | wc -l
CPUコア数 - 1 の数値を表示 (並列実行時に利用)
echo `expr $(sysctl -n hw.ncpu) - 1`
プロセス数 (CPUコア数 - 1) で、xargs 以降を並列実行。
brew list | xargs -P`expr $(sysctl -n hw.ncpu) - 1` -I{} sh -c 'brew uses --installed {} | wc -l | xargs printf "%20s is used by %2d formulae.\n" {}'
homebrew-rmtree で依存関係のない formula を削除 (libx11)
brew rmtree libx11
==> Examining installed formulae required by libx11...
\ 5 / 6
Can safely be removed
----------------------
libx11
libxcb
libpthread-stubs
libxau
libxdmcp
xorgproto
Proceed?[y/N]: y
==> Cleaning up packages safe to remove
Uninstalling /opt/homebrew/Cellar/libx11/1.7.3.1... (1,055 files, 7MB)
Uninstalling /opt/homebrew/Cellar/libxcb/1.14_1... (2,452 files, 7.3MB)
Uninstalling /opt/homebrew/Cellar/libpthread-stubs/0.4... (5 files, 6.6KB)
Uninstalling /opt/homebrew/Cellar/libxau/1.0.9... (20 files, 135.7KB)
Uninstalling /opt/homebrew/Cellar/libxdmcp/1.1.3... (11 files, 141.8KB)
Uninstalling /opt/homebrew/Cellar/xorgproto/2021.5... (264 files, 3.9MB)
Reference
by and for engineers - 2020-05-09 - Homebrew で使われていない formula を削除するhttps://yulii.github.io/brew-cleanup-installed-formulae-20200509.html
GitHub - beeftornado / homebrew-rmtree
https://github.com/beeftornado/homebrew-rmtree