How to Add a Random Quote to Terminal

Posted by Jonquil on Oct 13, 2011 6:31 PM EDT
xjonquilx | Mepis, Ubuntu, Fedora, Linux, Oh My!; By Jonquil McDaniel
Mail this story
Print this story

In this article I’m going to tell you how you can add a random quote to Terminal

In this article I’m going to tell you how you can add a random quote to Terminal, like what you see below:







Install The Fortune-Mod Package



First you will need to install the fortune-mod package. If you’re in Fedora you can do this by typing the following in to terminal as root or super user:



yum install fortune-mod



Once you have that installed, you can use the default fortunes file or you can create your own file with quotes in it.



Creating Your Own Quotes File



Create a file with Gedit. Create your quotes, adding a % variable between each new quote. Like this:



Quote 1

%

Quote 2

%

Quote 3



Save the file without a file extension. For the sake of this tutorial we will name the file quotes.



Adding Your Quotes File to Fortune-Mod



Now we need to create a .dat file for the quotes file. Open terminal in the location where you saved the quotes file and issue the following command:



strfile quotes



This will generate a quotes.dat file in the directory where you saved the quotes file. Now copy these files to the fortune-mod directory as root or super user by issuing the following commands:



cp quotes.dat /usr/share/games/fortunes

cp quotes /usr/share/games/fortunes



Test it in terminal by issuing the following command:



fortune quotes



You should have a random quote pop up.



Setting Up Random Fortunes in Terminal



This is perhaps the easiest part. Just open your ~/.bashrc file and add the following to the end of the file:



fortune quotes



Save and exit. Now every time you open up Terminal you should get something like this:

Full Story

  Nav
» Read more about: Story Type: Tutorial; Groups: Fedora, Ubuntu

« Return to the newswire homepage

This topic does not have any threads posted yet!

You cannot post until you login.