skwid138
10/23/2019 - 4:05 PM

When you open new shell/terminal window on macOS show cowsay with a fortune in rainbow colors.

When you open new shell/terminal window on macOS show cowsay with a fortune in rainbow colors.

Fortune with random Cowsay character and lolcat

  • On macOS using Homebrew run the following to install the packages

    brew install cowsay fortune lolcat

  • Next add the following to ~/.bash_profile

# If brew installed fortune, cowsay, and lolcat
# Upon opening a new shell show a cowsay character with a random forutune in rainbow colors
if [ -x /usr/local/Cellar/cowsay ] && [ -x /usr/local/Cellar/fortune ] && [ -x /usr/local/Cellar/fortune ]; then
    # Standard cowsay character (medium 5 lines)
    #fortune | cowsay | lolcat

    # Calf cowsay character (small 4 lines)
    fortune | cowsay -f small.cow | lolcat

    # Ghostbusters cowsay character (large over 10 lines)
    #fortune | cowsay -f ghostbusters.cow | lolcat

    # Satanic Goat cowsay character (medium 7 lines)
    #fortune | cowsay -f satanic.cow | lolcat

    # Moose cowsay character (medium 7 lines)
    #fortune | cowsay -f moose.cow | lolcat

    # Dinosaur cowsay character (large over 10 lines)
    #fortune | cowsay -f stegosaurus.cow | lolcat

    # Turtle cowsay character (large over 10 lines)
    #fortune | cowsay -f turtle.cow | lolcat

    # Linux Tux cowsay character (medium 9 lines)
    #fortune | cowsay -f tux.cow | lolcat

    # TODO: This isn't random and seems to always use the first character in the list
    # Random cowsay character
    #fortune | cowsay -f `ls -1 /usr/local/Cellar/cowsay/3.04/share/cows/*.cow | sort | head -1` -n | lolcat
fi
  • Source the updated source ~/.bash_profile