2 # prints random fortune to screen; note that -s is passed to fortune to
3 # prevent your screen from being flooded, and -w is enabled, since we're
4 # logging out of our session.
6 function lolcatcowsayfortune {
8 # randomly pick between cowsay and cowthink
9 declare -a cowsay_types=("cowsay" "cowthink")
10 cowsay_type=${cowsay_types[ $RANDOM % 2 ]}
11 #echo "Cowsay type: ${cowsay_type}"
13 # randomly pick an eye type
14 declare -a eye_types=("-b" "-d" "-g" "-p" "-s" "-t" "-w" "-y")
15 eye_type=${eye_types[ $RANDOM % 8 ]}
16 #echo "Eye type: ${eye_type}"
18 num_of_cows=`cowsay -l | grep -v "Cow files in" | tail -n +2 | wc -w`
19 which_cow=$(( RANDOM % ($num_of_cows+1) ))
20 this_cow=`cowsay -l | tail -n +2 | sed -e 's/\ /\'$'\n/g' | sed $which_cow'q;d'`
22 #echo "Number of cows: ${num_of_cows}"
23 #echo "Selected cow: ${this_cow}, from ${which_cow}"
24 fortune -s -w | $cowsay_type $eye_type -f $this_cow -n | lolcat
27 # require all components to be installed for function to execute
28 # fortune, with cowsay and random cows, and lolcat
29 if [ -n "$COWPATH" ] && [ -x "$(command -v cowsay)" ] && [ -x "$(command -v fortune)" ] && [ -x "$(command -v lolcat)" ]; then
32 echo "Missing required components, please check to ensure that fortune, cowsay, and lolcat are all installed, and that COWPATH is not null."