::fun with signature files

30 11 2007

Fortune is an itsy bitsy program in just about every Linux distribution that will give you a random quote when run.

jim@ingsoc:~$ fortune
Q: What do they call the alphabet in Arkansas?
A: The impossible dream.
jim@ingsoc:~$

This can make for minutes of fun if you’re staring at a command line wondering what to do next, but what if you want to do a little more with it?

I sometimes like to have a little fun with my email signature file, and a few months ago I thought it might be cool if I could generate a fortune for my email signature. Like a lot of people, I sometimes write a lot of email, and having to copy and paste a fortune every time I wrote an email would make the novelty quickly wear off. Instead, I decided to utilize the incredible power of bash scripting for this completely pointless endeavor. Following these simple steps can let you be as eL33t as me. Really.

And you know you want to be that cool.

So, here’s what I did.

First off, I made a directory in /home called sigs. This is just a handy place to put all of this coolness. Then inside that directory, I created a file called sigs. There’s some standard text that I want in all of my signatures, so I inserted that text. So far, that’s this:

jim@ingsoc:~$ mkdir sigs
jim@ingsoc:~$ cd sigs
jim@ingsoc:~/sigs$ nano sig

then you just insert your static text. In my case, that’s:

g o t j i m ?
http://www.gotjim.net

Now here’s where it gets really cool. Ready?

Fire up your favorite text editor–in my case, this is nano. Insert the following text:

#!/bin/bash

#Create a sig file based on fortune.

cp ~/sigs/sig.original ~/sigs/sig.new
/usr/games/fortune >> ~/sigs/sig.new
mv ~/sigs/sig.new ~/sigs/sig

Save the file and give it an obvious name. I chose sigmaker, but you can name it whatever you damn well please. I’m flexible like that.

Now, save the file and make it executable with chmod +x sigmaker.

Run it with a simple .sigmaker, and view the output with less sig.

g o t j i m ?

http://www.gotjim.net

Please remain seated until the ride has come to a complete stop.

Ohh, ahh.

Now you simply point your email program to your signature file. In the case of Thunderbird, you do this by going to Edit/Account Settings, and point to /home/you/sigs/sig. Open a new message to compose, and see your awesome skills in action.

But we’re not done here. Oh no. If you stop here, then the file never changes, and that defeats the point. So we’ll add this little slice of pimpness to our crontab for some real fun.

jim@ingsoc:~/sigs$ crontab -e

And do a little something like this:

# m h dom mon dow command
* * * * * /home/jim/sigs/./sigmaker

This will run sigmaker once every minute, giving you a new signature file with just about every email you write. You, of course, can change the timing however you like.

And there you have it, kids. A complete waste of time that’s good and good for you.

kisses,

jimbo

Advertisements