1 [[ -s ~/.bashrc ]] && source ~/.bashrc
3 # prints random fortune to screen; note that -s is passed to fortune to
4 # prevent your screen from being flooded, but cowsay does not have a similar
5 # option, and some cows are quite large; you may wish to remove -s given that,
6 # to enable access to a wider variety of fortunes
8 # dynamically build COWPATH based on commonly used locations for cowfiles,
10 declare -a cowpaths=( "/usr/local/git/cowfiles" "/usr/local/git/cowsay-files/cows" "/usr/local/share/localcows" "/usr/local/share/cows" "/usr/share/cowsay" )
12 for cowpath in "${cowpaths[@]}"; do
13 if [ -e $cowpath ]; then
14 COWPATH="$cowpath:$COWPATH"
18 if [ -n "$COWPATH" ]; then
22 function lolcatcowsayfortune {
24 # randomly pick between cowsay and cowthink
25 declare -a cowsay_types=("cowsay" "cowthink")
26 cowsay_type=${cowsay_types[ $RANDOM % 2 ]}
27 #echo "Cowsay type: ${cowsay_type}"
29 # randomly pick an eye type
30 declare -a eye_types=("-b" "-d" "-g" "-p" "-s" "-t" "-w" "-y")
31 eye_type=${eye_types[ $RANDOM % 8 ]}
32 #echo "Eye type: ${eye_type}"
34 num_of_cows=`cowsay -l | grep -v "Cow files in" | tail -n +2 | wc -w`
35 which_cow=$(( RANDOM % ($num_of_cows+1) ))
36 this_cow=`cowsay -l | tail -n +2 | sed -e 's/\ /\'$'\n/g' | sed $which_cow'q;d'`
38 #echo "Number of cows: ${num_of_cows}"
39 #echo "Selected cow: ${this_cow}, from ${which_cow}"
40 fortune -s | $cowsay_type $eye_type -f $this_cow -n | lolcat
43 # require all components to be installed for function to execute
44 # fortune, with cowsay and random cows, and lolcat; here instead of .bashrc
45 # to prevent remote eommands from failing due to output being generated
46 if [ -n "$COWPATH" ] && [ -x "$(command -v cowsay)" ] && [ -x "$(command -v fortune)" ] && [ -x "$(command -v lolcat)" ]; then
49 echo "Missing required components, please check to ensure that fortune, cowsay, and lolcat are all installed, and that COWPATH is not null."