Skip to content

Instantly share code, notes, and snippets.

@dlvhdr
Last active August 6, 2022 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlvhdr/c4edfbcab07276ee2c8de064d157a1db to your computer and use it in GitHub Desktop.
Save dlvhdr/c4edfbcab07276ee2c8de064d157a1db to your computer and use it in GitHub Desktop.
Interactively uninstall brew packages with gum (https://github.com/charmbracelet/gum)
#!/bin/bash
export HOMEBREW_NO_AUTO_UPDATE=1
options=$(\
brew bundle dump --describe --file - | \
grep -E "^(brew|cask|#)" | \
sed -E 's/^(brew|cask) \"(.*)\"(,.*)?/\2/' | \
sed "s/#//" | \
while read -r first;
do
if [[ $first != "#*" ]]; then
read -r second
echo "$second ($first)";
else
echo "$first"
fi
done \
)
echo "$options" | gum choose --no-limit | sed -E "s/(.* )\(.*\)/\1/" | xargs brew uninstall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment