aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMike McQuaid2013-06-29 13:25:55 +0100
committerMike McQuaid2013-06-29 13:27:18 +0100
commite62ad08af8f6555e838f8c21ab4ad1ac5e47b26e (patch)
tree5a8cdd14f735e49435c711613ca51751bb9ce6bc /Library
parente6354b84a6eb793f9c04d55c098501566301fec3 (diff)
downloadbrew-e62ad08af8f6555e838f8c21ab4ad1ac5e47b26e.tar.bz2
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.
Diffstat (limited to 'Library')
-rwxr-xr-xLibrary/Contributions/cmd/brew-cleanup-installed22
1 files changed, 22 insertions, 0 deletions
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