From 1c2839cec522014790ccd0e3eae2d72fa8da36a3 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 29 Jun 2013 13:25:55 +0100 Subject: brew-cleanup-installed: add new external command. brew-cleanup-installed: uninstall all non-whitelisted Homebrew formulae. Useful for maintainers/testers who regularly install lots of formulae they don't actually use. Populate ~/.brew-cleanup-installed with the formulae you want to keep installed. All others will be uninstalled when brew-cleanup-installed is run. --- Library/Contributions/cmd/brew-cleanup-installed | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 Library/Contributions/cmd/brew-cleanup-installed (limited to 'Library') diff --git a/Library/Contributions/cmd/brew-cleanup-installed b/Library/Contributions/cmd/brew-cleanup-installed new file mode 100755 index 000000000..9ce9ccbe5 --- /dev/null +++ b/Library/Contributions/cmd/brew-cleanup-installed @@ -0,0 +1,22 @@ +#!/bin/sh +# brew-cleanup-installed: uninstall all non-whitelisted Homebrew formulae. +# +# Useful for maintainers/testers who regularly install lots of formulae +# they don't actually use. +# +# Populate ~/.brew-cleanup-installed with the formulae you want to keep +# installed. All others will be uninstalled when brew-cleanup-installed is run. + +# Exit on any command failures +set -e + +BREW_CLEAN_WHITELIST=~/.brew-cleanup-installed +# Do nothing and exit if the file doesn't exist. +[ -s $BREW_CLEAN_WHITELIST ] +BREW_LIST=$TMPDIR/brew-installed-list + +# comm needs both lists to be sorted so ensure the dotfile is sorted first. +sort --unique ~/.brew-cleanup-installed --output ~/.brew-cleanup-installed +brew list > $BREW_LIST +comm -13 $BREW_CLEAN_WHITELIST $BREW_LIST | xargs brew uninstall +rm $BREW_LIST -- cgit v1.2.3