Skip to content

Instantly share code, notes, and snippets.

@connorworley
Last active March 19, 2018 23:26
Show Gist options
  • Save connorworley/4e4bfb715754c88fd9b8 to your computer and use it in GitHub Desktop.
Save connorworley/4e4bfb715754c88fd9b8 to your computer and use it in GitHub Desktop.
#!/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