Skip to content

Instantly share code, notes, and snippets.

@khchanel
Created June 2, 2015 02:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save khchanel/2425f2339921c2d1cec5 to your computer and use it in GitHub Desktop.
Save khchanel/2425f2339921c2d1cec5 to your computer and use it in GitHub Desktop.
fortune telling with random cowsay
#!/bin/bash
# cowsayfortune
# Author: Nelson Chan <khchanel>
#
# fortune telling with random cowsay
# change paths accordingly for your system
FORTUNE="/usr/local/Cellar/fortune/*/bin/fortune"
COWSAY="/usr/local/Cellar/cowsay/*/bin/cowsay"
SHUF="/usr/local/Cellar/coreutils/*/bin/gshuf"
COWSAY_PATH="/usr/local/Cellar/cowsay/*/share/cows"
GREEN='\033[0;32m'
NOCOLOR='\033[0m'
if [ -x ${COWSAY_PATH} -a -x ${FORTUNE} -a -x ${SHUF} ]; then
echo -e ${GREEN}
${FORTUNE} | ${COWSAY} -f "$(ls ${COWSAY_PATH} | ${SHUF} -n1)"
echo -e ${NOCOLOR}
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment