How to add a random quotation to your signature in PINE

by A. Fornasiero

I will explain how to insert some random quotation (aka fortune) in your signature of your mails, using PINE, under unix/linux.

First, you need a program that generates random fortunes.
I use the common unix program fortune, that on my system is under the path /usr/games/fortune. Check that this is also the case on your system, by running the above line from your shell: it will produce a random quotation.
If this is not the case, try to find it, via the command
locate fortune
which will give you a list of files containing the word fortune in their name.

Second, you will have to create a program that produces your signature (let us call it signature.sh), with the random quotation. Here is an example:

#!/bin/sh
#produces my signature with a random quotation on standard output
echo '-- '
echo 'Second line'
/usr/games/fortune -s
echo ''
echo 'Fifth line'
echo ''
echo 'Homepage <http://www.dm.unipi.it/~fornasiero/>'

The option -s in the line /usr/games/fortune -s forces fortune to produce only short citations. If you want also long citations, drop that option.
Move the file signature.sh into the bin directory in your HOME directory, and give it executable permissions, via the command
chmod u+x signature.sh
Now run the program signature.sh, and check that the output is indeed your desired signature, with a random quotation. In our case, by running signature.sh, we get the following output:

--
Second line
... this must be what it's like to be a COLLEGE GRADUATE!!

Fifth line

Homepage <http://www.dm.unipi.it/~fornasiero/>

Third, you need to instruct PINE to use the file signature.sh to produce your signature.
Launch PINE, go to the main menu, and from there to the -> setup -> config menu. Check that the option literal-signature has no value set (it should show <No Value Set> as value).
Change the option signature-file to
bin/signature.sh |
(the | at the end is important).
Exit the setup menu and save the changes: you should now be ready.

Finally, test that everything is working, by composing a new message.

If you want to use a specific fortune file, for instance the file literature (which contains various literary quotations), give the name of the file as argument to fortune, namely:
/usr/games/fortune -s literature

Create your own fortunes

If you want to use your own fortunes, do the following. First, create a directory in your home page, let's call it fortunes.
In this directory, create a text file containing your favorite quotations, let's call it quotations.
The format of this quotations file is the following:

Ta panta rhei
		-- Heraclitus
%
Reserve your right to think, for even to think wrongly
is better than not to think at all
		-- Ypatia (350-370?--415 AD)

Note the % character (percent) separing the quotations, and the fact that the file ends with a newline and no %. Then, enter the directory fortunes, and use the command
/usr/sbin/strfile quotations
It will create the file quotations.dat in the directory fortunes.
If the program strfile is not in the indicated path, find it using locate.

Test that the new fortune database works, via the command (from inside the directory fortunes)
/usr/games/fortune quotations
or (from your HOME dir)
/usr/games/fortune fortunes/quotations

You can have more than one file of quotations in your fortunes directory: simply repeat the above procedure for each additional file.

Finally, if you want to use the quotations file in your signature, modify the signature.sh file in any of the following ways:

/usr/games/fortune -s literature ~/fortunes
if you want to use short quotations from the literature file, and the database in your fortunes directory;
/usr/games/fortune -s ~/fortunes
if you want to use short quotations from your database only;
usr/games/fortune -s all ~/fortunes
if you want to use the standard fortunes together with your ones.
Back to homepage
Valid XHTML 1.0! Valid CSS!
Please write me if you have suggestions, find mistakes and/or some links are not working.

My e-mail address is fornasiero at mail.dm.unipi.it
This page address: http://www.dm.unipi.it/~fornasiero/signature.html

Last modified: Wed Jun 6 15:16:05 CEST 2007 by A. Fornasiero