Skip to content

Instantly share code, notes, and snippets.

@bezhermoso
Last active August 20, 2018 22:59
Show Gist options
  • Save bezhermoso/97b1ce74e3233f394c3c2068c7f66008 to your computer and use it in GitHub Desktop.
Save bezhermoso/97b1ce74e3233f394c3c2068c7f66008 to your computer and use it in GitHub Desktop.
Create an inventory of installed Homebrew formulae, preserving flags
#!/usr/bin/env bash
brew list | while read formula; do
command="brew install $formula"
flags="$(brew info $formula | grep -i "built from source .* with:" | cut -f 11- -d' ')"
echo $command $flags
done
# Usage:
# ./brew-inventory.sh >! brew-formulae.txt
# To install from inventory output i.e. brew-formulae.txt:
# eval "$(cat brew-formulae.txt)"
@bezhermoso
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment