Linux — ASCII Art in Terminal Sessions

I was wondering today…I used to see this screenshot of a ASCII cow in a terminal that was giving some sort of advice or fortune. After a little googling I found the application fortune which shows you a simple fortune when run from a terminal on linux/unix. I also found the application cowsay which is the app that shows the ASCII art of animals with a comic balloon. By default a cow, however there are many others. I chose tux.

$ fortune | cowsay
 _______________________________________
/ Don't go around saying the world owes 
| you a living. The world owes you      |
| nothing. It was here first.           |
|                                       |
 -- Mark Twain                         /
 ---------------------------------------
           ^__^
           (oo)_______
            (__)       )/
                ||----w |
                ||     ||

 

Why the pipe? because fortune echos a string, and cowsay reads in a string.

Now the problem was I had to type the command every single time. To solve this we turn to your users .bashrc file. Located ~/.bashrc for Ubuntu users. Edit the file with your favorite text editor and add the following lines at the bottom.

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

 


(if statement checks to make sure both cowsay and fortune are installed)
Now, everytime you open a terminal or command prompt you’ll have a cool animal telling you a fortune!

Sources:
http://askubuntu.com/questions/16428/showing-a-cowsays-in-every-new-terminal-session
Cool Android app here. This will send SMS text messages from your phone as cowsay!!