Random quotes and creatures using fortune and cowsay in Linux terminal


Recommended Posts

 

 

Random quotes and creatures using fortune and cowsay in Linux terminal
fortune is a simple program that displays a pseudorandom message from a database of quotations that first appeared in Version 7 Unix. The most common version on modern systems is the BSD fortune, originally written by Ken Arnold. Distributions of fortune are usually bundled with a collection of themed files, containing sayings like those found on fortune cookies (hence the name), quotations from famous people, jokes, or poetry.
Random-quotes-and-creatures-using-Fortun
cowsay is a program which generates ASCII pictures of a cow with a message. It can also generate pictures using pre-made images of other animals, such as Tux the Penguin, the Linux mascot. Tony Monroe is credited as the original author. Since it is written in Perl, it is adaptable to other systems such as Microsoft Windows. .cow files for cowsay exist which are able to produce different variants of ?cows?, with different kinds of ?eyes?, and so forth. It is sometimes used on IRC, desktop screenshots, and in software documentation. It is more or less a joke within hacker culture, but has been around long enough that its use is rather widespread. In 2007 it was highlighted as a Debian package of the day.
Install Fortune

You can install fortune in Debian, Ubuntu or Kali Linux or any aptitude/apt-get based distro using the following command:

apt-get install fortune
(or)
sudo apt-get install fortune

Usually fortune is available in all the basic standard repositories, otherwise just add them for your respective Linux version.

You can install fortune in Redhat, CentOS, Fedora of any yum based Linux distros using the following command:

yum install fortune
(or)
sudo yum install fortune
Install Cowsay

You can install cowsay in Debian, Ubuntu or Kali Linux or any aptitude/apt-get based distro using the following command:

apt-get install cowsay
(or)
sudo apt-get install cowsay

Just like fortune, cowsay is available in all the basic standard repositories, otherwise just add them for your respective Linux version.

Similar to fortune, you can install cowsay in Redhat, CentOS, Fedora of any yum based Linux distros using the following command:

yum install cowsay
(or)
sudo yum install cowsay
Option 1. Random fortune and cowsay for single user

To add random fortune and cowsay for a single user, you need to edit .bashrc file in the users home directory.

vi ~/.bashrc

Now add the following line at the bottom of the file:

if [ -x /usr/games/cowsay -a -x /usr/games/fortune ]; then
   fortune | cowsay -f $(ls /usr/share/cowsay/cows/ | shuf -n1)
fi

Save and exit. Reopen terminal and you will see a random creature quoting a different phrase/jokes for that user.

 

Option 2. Random fortune and cowsay for all users

To add random fortune and cowsay for a all users, you need to edit /etc/bash.bashrc file

vi /etc/bash.bashrc

Now add the following line at the bottom of the file:

if [ -x /usr/games/cowsay -a -x /usr/games/fortune ]; then
   fortune | cowsay -f $(ls /usr/share/cowsay/cows/ | shuf -n1)
fi

Save and exit.

Reopen terminal and you will see a random creature quoting a different phrase/jokes for all users globally.

 
 

 

 

 

QZI5JnH.jpg

  • Like 1
Link to comment
Share on other sites

  • 1 year later...
  • 1 month later...

Thanks, Simon, this is rather nice. I already have Wanda the Fish in my system tray and can click on her whenever I want a fortune. Now it's also there for me in a terminal with ASCII animals! :) 

 

As for fortunes databases, there's a list of ones here: http://packages.ubuntu.com/search?suite=default&section=all&arch=any&keywords=fortune&searchon=names

 

I have the English and Spanish ones, but, as I am easily scandalised, I don't have any of the ones ending in 'off'.

Link to comment
Share on other sites

This topic is now closed to further replies.