Subscribe

RSS Feed (xml)

Powered by Blogger

Wednesday, November 3, 2010

Get Mint Like Fortune-Cookie in your Ubuntu Terminal !


Most of you might have noticed a cool feature which is available in Linux-Mint,
each time when you open a Terminal, it will display a cool - simple quote.
We don't have this option in Ubuntu. but we can have it. 
First we have to install the Fortune Cookie Database in our system. we can do that by typing the following in a terminal. 

sudo apt-get install fortune-mod cowsay 
sudo apt-get install fortune
Now we have the database installed in our system. have a try by typing the following: 
fortune
Now let us borrow a cool script from the Mint people.
open  gedit (or any editor of your choice ) and type the following script in it and save it in /usr/bin/ by the name fortune. 


#!/bin/bash
RANGE=4
number=$RANDOM
let "number %= $RANGE"
case $number in
0)
cow="small"
;;
1)
cow="tux"
;;
2)
cow="koala"
;;
3)
cow="moose"
;;
esac

RANGE=2
number=$RANDOM
let "number %= $RANGE"
case $number in
0)
command="/usr/games/cowsay"
;;
1)
command="/usr/games/cowthink"
;;
esac

/usr/games/fortune | $command -f $cow

Now change the mode of this file to executable by typing the following in the terminal
sudo chmod +x /usr/bin/fortune

finally type the following in the terminal

sudo echo "/usr/bin/fortune" >> ~/.bashrc

Done !!! Now you will get a cool Fortune-Cookie , each time when you open the terminal...

Enjoy !! and Happy Hacking !!

Share this post :

4 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. well, the script works..but when you open a bash console by typing sudo bash....you get an error

    cowthink: Could not find small cowfile!


    ne ideas???

    ReplyDelete
  3. so Fortune which produces the quotes wants to use the /usr/share/cowsay/cows/small.cow file, but it does not exist.

    as a temporary fix until the cowsay package is updated, do the following command in a terminal window:

    sudo ln -s /usr/share/cowsay/cows/default.cow /usr/share/cowsay/cows/small.cow

    This will make a symbolic link from the default.cow file, which appears to be the small cow to a link file named small.cow.

    ReplyDelete