Skip to content

Instantly share code, notes, and snippets.

@garettmd garettmd/brewlette.sh
Last active Oct 3, 2018

Embed
What would you like to do?
Suggest a random package from homebrew
#!/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
@garettmd

This comment has been minimized.

Copy link
Owner Author

garettmd commented Jul 11, 2018

Put this file under /usr/local/bin so that it's in your PATH. Then enjoy discovering new packages in homebrew.

@garettmd

This comment has been minimized.

Copy link
Owner Author

garettmd commented Oct 3, 2018

4th revision tightened up code according to shellcheck suggestions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.