Saturday, 19 January 2013

Cool messages on terminal emulators

 I have talked about editing "~/.bashrc" in Change Command Prompt article earlier. Similarly, you can customise your terminal further by editing this file. I have described one such customisation below. If you are feeling bored on seeing the blank terminal every time you open it and you are cool with the idea of reading some random messages / quotations then you need to use a program called "fortune". Fortune displays a random text string from a set of files in a certain format. Fortune is installed by default on openSUSE 12.2 / GNOME 3.4.2.
  All you need to do now is add a small script at the end of the file "~/.bashrc" to display the quotations in terminal. This script should already be available in  the file "~/.profile" where "~" your home directory. You can copy paste it from there and remove the comment symbols(#) from the script for it to work. The first line in the below checks whether fortune exists on you machine. The echo lines are for displaying empty lines before and after the random quotations. Finally you close the "if" condition.
if [ -x /usr/bin/fortune ] ;
then
    echo
    /usr/bin/fortune
    echo
fi
Sample output from gnome-terminal on openSUSE 12.2 / GNOME 3.42
Gnome Terminal Fortune
If you need shorter messages you can use -s option
if [ -x /usr/bin/fortune ] ;
then
    echo
    /usr/bin/fortune -s
    echo
fi
 There are a lot of other customisation options available in fortune for which you need to read the man pages (manual). You may check out man here Demystifying Man

No comments:

Post a Comment