Skip to content

Instantly share code, notes, and snippets.

@ampersanda
Created June 26, 2019 02:12
Show Gist options
  • Save ampersanda/6b2e0ef0a395741e3a6f2c4c311a9419 to your computer and use it in GitHub Desktop.
Save ampersanda/6b2e0ef0a395741e3a6f2c4c311a9419 to your computer and use it in GitHub Desktop.
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment