Thursday, October 20, 2011

Fortune Cookie Cowsay

I can’t believe this hasn’t been covered yet! So I thought I’ll cover it at least.
Today, I’m feeling in a good mood. Don’t know what, perhaps its the fortune’s I have been getting. Sadly though these fortunes aren’t magical and it wasn’t destiny that I was to get this fortune. Or maybe it was, who knows if rand() is rigged sometimes just to favor you?
So if your feeling in the mood for a fortune cookie, fire up your terminal and start typing!
fortune

Hopully that was able to cheer you up..No?
Well lets see what kind of fortunes are installed on my machine
fortune -f

Which gives me:
52.24% fortunes
31.76% literature
16.00% riddles

So on my Ubuntu Dapper Drake machine, I did a apt-cache search fortunes (on my and behold! More fortunes! Ranging from mario, to offensive, to different languages. So I decided to install some of them for fun.
To run a specific fortune just enter:
fortune FORTUNENAME

Now to wrap it up! This requires cowsay to be installed.
cowsay `fortune`

And tada, we get our fortune wrapped in beautiful ascii art.
 _________________________________________
/ Live in a world of your own, but always \
\ welcome visitors.                       /
 -----------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Similarly you can change what type of image is displayed.
So if I run:
cowsay -f tux `fortune`

 _______________________________________
/ You have an ability to sense and know \
\ higher truth.                         /
 ---------------------------------------
   \
    \
        .--.
       |o_o |
       |:_/ |
      //   \ \
     (|     | )
    /'\_   _/`\
    \___)=(___/

Ain't he cute? If you want you can make your own asii art actually!
For a list of what cowsay's you have run:
cowsay -l
So I hope you enjoy your fotune today.
If you have the disclaimer package installed for fortune, for fun add to your .bashrc
fortune disclaimer

and now you'll get disclaimers everytime you start your Terminal!

Resources:
Bash#ASCII_art.2C_fortunes_and_cowsay

No comments: