Wednesday, July 9, 2014

Terminal Tricks : Cowsay and Fortune

When you start terminal, your operating systems runs few scripts to load your settings and initialize your terminal environment.

One of these files is ~/bash.bashrc .

You can edit this file to customize terminal to suit your needs.

We will be using two applications :

1. Cowsay

sumit@teardrop:~$ cowsay sumit
 _______
< sumit >
 -------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Cowsay draws a nice cow on your terminal with the dialog box of the text that you have as input.

2. Fortune

sumit@teardrop:~$ fortune

Sheriff Chameleotoptor sighed with an air of weary sadness, and then
turned to Doppelgutt and said 'The Senator must really have been on a
bender this time -- he left a party in Cleveland, Ohio, at 11:30 last
night, and they found his car this morning in the smokestack of a British
aircraft carrier in the Formosa Straits.'
  -- Grand Panjandrum's Special Award, 1985 Bulwer-Lytton
     bad fiction contest.

Now when we pipe output of fortune to cowsay :

sumit@teardrop:~$ fortune | cowsay
 ______________________________________
/ You will remember something that you \
\ should not have forgotten.           /
 --------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

This looks fancy. Now add this to bottom line of you ~/bash.bashrc file. If this file is absent, then create one in your home folder. Every time you run terminal, you will get a cow with fortune for that run.

Check this youtube video for demo.