-
-
Save papricasix/22614401c7a05f8a7b4e4aaeaa167765 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/zsh | |
declare -A visited_formulas | |
check_formulas() { | |
for formula in "$@"; do | |
if [[ -z `brew uses --installed $formula` ]] && ! (( ${+visited_formulas[$formula]} )) && [[ $formula != "brew-cask" ]]; then | |
read "input?$formula is not depended on by other formulas. Remove? [Y/n] " | |
visited_formulas[$formula]=1 | |
if [[ "$input" == "Y" ]]; then | |
brew remove $formula | |
check_formulas `brew deps --1 --installed $formula` | |
fi | |
fi | |
done | |
} | |
echo "Searching for formulas not depended on by other formulas..." | |
check_formulas `brew list` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is great! I use it for ~2 years now. Recently I tweaked it a little bit: upgraded to latest
brew
CLI behaviour (brew list
wants a--formula
argument) and added aKEEP_FORMULAS
feature. Have a look at https://gist.github.com/cgrothaus/ef9004404e0d168c3d150c409c9d5526 if you like that.