The Buffy Quote Generator

While this probably goes in the category of "I need a life" I've found that Buffy usually has one or two very funny scenes per show. So, I created this quote generator--unlike fortune, which uses a database, this is a simple shell script.

Although this should be obvious, just in case some Buffy fans find this page doing web searches, this quote generator only works for Unix type operating systems. It doesn't work on Windows. It might work in Cygwin, but I haven't tried it. It will also work on Mac OS X.

If you're using Linux then download the Linux version here.

The BSD version is here. The only difference is the way I generate the variable that picks a random quote. If you're on a Mac then you might try the uncompressed version which is here

As BSD people almost always like to learn this sort of thing, I'll mention that the reason for the difference between the Linux and BSD versions is that /bin/sh doesn't have the RANDOM variable but BSD does have the jot command. If you have bash installed on your BSD box, the Linux version will work--just change the top line so that it calls bash with BSD's path. (/usr/local/bin in FreeBSD and /usr/pkg/bin in NetBSD)

I only mention this for beginners--more experienced BSD users probably know that in NetBSD for example, you could use the Linux version with the built in /bin/ksh. However, for purposes of this brief explanation, we'll assume that you're either using sh or bash in both BSD's. Most of the time, I'll only give the FreeBSD example, change the local in the FreeBSD path to pkg if you're using NetBSD.

#!/usr/local/bin/bash

If you use lynx, just hitting enter when the download link is highlighted will, at least on my system, just produce some garbage text. However, once the link is highlighted, if you hit d for download, it should download without problem.

If you're using w3m then, hit Esc + Enter and it should save the bz2 file correctly. If you just hit enter, you'll have the same problem mentioned above, seeing a screen of garbage characters

In a graphical browser, like konqueror, right click and choose the save link as or save as. Or perhaps the simplest is to, at a command prompt, assuming you have wget installed

wget http://srobb.net/buffquote.bz2

If you are using BSD then change that to

wget http://srobb.net/bsdbuff.bz2

(Thanks to Nicholas Jeffery for those two suggestions, which I'd been too lazy to add. In FreeBSD, there is also the builtin fetch command. Gentoo Linux also has it, but Fedora, Arch, Slack and NetBSD don't)

fetch http://srobb.net/bsdbuff.bz2

Once downloaded, decompress it with

bunzip2 buffquote.bz2

If you're using BSD then it would be

bunzip2 bsdbuff.bz2

If you took the Mac version, then you don't have to do that.
Then, in your .bashrc simply add the line

sh ~/buffquote

The above is for Linux. In BSD add that line to your .login file, at the end.

Then, when you log in, you'll get one of the quotes to greet you.

Originally, there were only 100 quotes, however Anthony Floyd has been kind enough to add another 178 of them, so you now have 278 quotes,thanks to him. (I've added a few since, but won't be updating each time I do it--you'll see when you download the file how many there are)

There's other ways to do it, such as making it executable, putting it in /usr/local/bin, etc etc, however, if you're experienced, you probably know how to do that--if you're a novice, then you probably just want it to work and the method above is probably the quickest.

I only briefly played with this on Mac's OS X. To run it, open a terminal window, go to the directory holding it and type

sh buffquote

Sorry for the lack of info on the Mac, but it's my wife's machine and she had things to do. :)

You can add your own quotes of course. The pattern should be fairly obvious--in the Linux version change the 278 in the $((RANDOM%278+1)) to reflect however many quotes you're adding--for instance, if you're only adding one quote, then change it to 279. In the BSD version, change the 278 in the $(jot -r 1 1 278) for the numb variable.

It's a simple case statement--if you're not familiar with the syntax it should still be relatively easy from looking at the existing quotes. If not then, for the first quote that you added it would be

101)echo "Your quote here."
;;
Note that you should only have a double quote (") at the beginning and end of the quote--in other words, you can't do echo "Buffy: "Hi there". It would have to be echo "Buffy: Hi there"

There are other ways that will work as well, such as escaping quotes with backslashes, however, the brief explanation above is aimed at the newcomer to scripting--more experienced scripters know these things already. The aim here is to allow the scripting novice to add a quote if they wish to do so.

Also note, that as mentioned above, the number is no longer 278. I add quotes here and there when I get bored.

To add it to your mutt signature, copy it, remove the second line that says clear (otherwise, depending upon your editor, you get peculiar characters) and add to your .muttrc (This is assuming you have the quote generator in your home directory--otherwise substitute ~ with the path to it)

set signature="sh ~/buffquote |"

(If you are using FreeBSD and wound up with the Linux version, which requires bash then change that to

set signature="/usr/local/bin/bash ~/buffquote |"

If you're using NetBSD then it'd be

set signature="/usr/pkg/bin/bash ~/buffquote |"

Eric Johnson, a programmer friend, and also an Arch Linux package maintainter, (His home page is here) explained to me how to make a fortune mod out of this file. However, after I kept messing up the text file before running strfile on it, he lost patience and stripped out the shell script stuff himself. Thank you Eric. I've uploaded his .dat file, consisting of the quotes. You can get it here.

To use it, stick it wherever your distro sticks its fortune mods--in FreeBSD it's in /usr/share/games/fortune. If you look at it, you'll see it's just a text file with a lot % signs in between. Now, generate the dat file which is required by fortune.
strfile buffy

You'll see something like
"buffy.dat" created
There were 281 strings
Longest string: 858 bytes
Shortest string: 38 bytes

Now, in your fortune directory, you should have a file called buffy and another one called buffy.dat. Then you can call it with

fortune buffy

If you are using Arch Linux, however, you can (modest cough) simply install the module with

pacman -Sy fortune-mod-buffy

(Eric is actually the contributor though he wanted to give me credit--however, as he did all the work, I had the good grace to refuse.) Anyway, yes, it is an Arch Linux package.

Enjoy and thanks for using it.