Showing a "cowsay" fortune in every new terminal session

  • Open the file ~/.bashrc (or /etc/bash.bashrc if it should work globally for all users).

  • Add the following at the bottom of the file:

    if [ -x /usr/games/cowsay -a -x /usr/games/fortune ]; then
        fortune | cowsay
    fi
    

BONUS: If you're using bash you can make a ~/.bash_logout file and it will execute that when you log out. Make sure to have it sleep for a second or so, or you'll never see it.

cowsay "See you later"; sleep 1


I would consider setting a limit to the size of the fortune command requested.

fortune -s | cowsay

This will produce at most 160 characters. This is a good size for a greeting, anything more than that and long fortunes will flood your terminal.