#!/usr/bin/env bash
# Utility to suggest a new package to try from Homebrew
# Simply run and it will give you a new package to try out
files=(/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/*)
total=${#files[@]}
rando=$((RANDOM % total))
package=$(basename "${files[rando]}" .rb)
printf "\\nTry out a random homebrew package!\\n\\n"
brew info "${package}"
if [[ $(command -v pbcopy) ]]
then
echo "brew install ${package}" | pbcopy
printf "\\nCommand \"brew install %s\" copied to clipboard\\n" "$package"
else
printf "\\nUse \"brew install %s\" to try it out\\n" "$package"
fi