6

My bashrc issues a cow from cowsay and with a random fortune.

Like this:

echo -e "\e[00;33m $(fortune -a -o -s | cowsay -f $(ls /usr/share/cowsay/cows/ | shuf -n1) | sed -e 's/^/       /g')\e[00m"

This works on Linux Mint but I moved to Arch Linux, and the cowfile directory is different now.

Is there a standard way to figure out the cow directory?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
RSFalcon7
  • 4,367
  • 6
  • 30
  • 56

1 Answers1

6

cowsay -l lists all avaliable cowfiles.

cowsay -l | tail -n +2 | tr ' ' '\n' | shuf -n 1

tail -n +2 removes the first line, which states the path to Cow files that will be used ("Cow files in /usr/share/cows:" in cowsay 3.02-8 in Arch linux), tr ' ' '\n' separates the output into lines and, finally, shuf -n 1 chooses a random cow.

msarahan
  • 103
  • 1
  • 5
RSFalcon7
  • 4,367
  • 6
  • 30
  • 56