Previous Page
PCLinuxOS Magazine
Article List
Next Page

Tip Top Tips: Terminal With "Talking Cow"

Editor's Note: Tip Top Tips is a new monthly column in The PCLinuxOS Magazine. Each month, we will feature -- and possibly even expand upon -- one tip from the PCLinuxOS forum. The magazine will not accept independent tip submissions specifically intended for inclusion in the Tip Top Tips column. Rather, if you have a tip, share it in the PCLinuxOS forum's "Tips & Tricks" section. Your tip just may be selected for publication in The PCLinuxOS Magazine.

This month's Tip Top Tip comes from PCLinuxOS forum user zen-subz.

Just to make my 'terminal' experience a bit enjoyable, I have done a bit of customization. These are the steps that I have followed:

1. Install fortune-mod and cowsay (from Synaptic).

2. Create a script with the following code, and name it cowscript.

3. Make it executable (chmod 755).

4. Place this 'cowscript' in /usr/local/bin.

5. Edit the .bashrc file and insert the word 'cowscript' in the last-line (without quotes). Save and exit.

Open your terminal(s), which will now look like this:


Without a doubt, the combined installation of cowsay and fortune-mod can make your terminal sessions much more fun, and even humorous. Heck ... either program is fun installed and run by itself, so linking them together like this can generate all kinds of laughs. So, let's dig a little deeper into these two command line programs. (Pssst! No one says you have to be serious all of the time!).

Fortune-mod does exactly what you would think it should do: it displays famous (or infamous) quotes and quips on your computer in your terminal window. Combined with the cowsay program, it can make your cow sound quite witty and smart. The "fortunes" are stored in your /usr/share/games/fortunes/ directory. While some distros package fortune-mod with potentially "offensive" quotes and quips (typically stored in the /off subdirectory), the PCLinuxOS package is lacking those. Still, the -a command line switch will allow fortune-mod to display all quotes and quips, both offensive and non-offensive. At a command line prompt in a terminal session, simply entering fortune -a will display a random quote or quip in your terminal window. I recommend reading through the fortune-mod man page for more information, should you so choose. These basics will cover our needs for now.

Cowsay is responsible for drawing the fun ASCII pictures in your terminal window. Simply entering cowsay "Say something" will display the default cow saying the text in quotes. That's the simplest way to run cowsay. But, there is so much more you can do.

At a command line prompt, enter cowsay -l (small L). It will list out all of the various "cows" that are available. Below are the cows that are available on my computer.

apt   beavis.zen   bong   bud-frogs   bunny   calvin   cheese   cock   cower   daemon   default   dragon   dragon-and-cow   elephant   elephant-in-snake   eyes   flaming-sheep   ghostbusters   giraffe   gnu head-in   hellokitty   kenny   kiss   kitty   koala   kosh   luke-koala   mech-and-cow   meow   milk   moofasa   moose   mutilated   phaco   pumpkin   ren   satanic   shark   sheep   skeleton   small   small-duck   sodomized   sodomized-sheep   stegosaurus   stimpy   supermilker   surgery   suse  telebears   three-eyes   turkey   turtle   tux   udder   vader   vader-koala   www

There is also a command line switch, -f [name of cow] text to display that is also supposed to allow you to specify a particular cow file to use. When used incorrectly -- as in forgetting to specify text to display -- your terminal will just sit there. You will have to use Ctrl + C to break out of the endless loop you created. Your mileage may vary when using the cowsay command at a terminal prompt.

Depending on whether you want your cow to say something or think something, there are two valid commands to choose from. Using cowsay will cause your cow to "say" something, and is indicated by slashes leading from the cow image to the speech bubble. But using cowthink will cause your cow to think something, indicated by little "o" characters leading from the cow image to the speech bubble.

You can also specify special characters to use for the cow's eyes, by using the -e command line switch. The character string must be two characters, and the default is "oo" (without the quotes). If you choose to use the eye string, it must appear before the -f [name of cow] command line switch. Similarly, you can specify the character string to use for the cow's tongue, by using the -T command line switch. Just as with the command line switch to control the appearance of the cow's eyes, the tongue switch must be two characters long.

There are several provided modes which change the appearance of the cow, depending on its particular emotional/physical state. The -b option initiates Borg mode; -d causes the cow to appear dead; -g invokes greedy mode; -p causes a state of paranoia to come over the cow; -s makes the cow appear thoroughly stoned; -t yields a tired cow; -w is somewhat the opposite of -t, and initiates wired mode; -y brings on the cow's youthful appearance.

Custom Cows

Want your own "custom cows?" You can have those, as well. The cows are, after all, just ASCII art. Head on over to Christopher Johnson's ASCII Art Collection website, and grab some existing (already created) ASCII art images. His website has been continuously online since 1994 and the days of Netscape 1.0. He has 23 different major categories of ASCII art, with many of those categories further split down into subcategories. Are you a Trekker looking for some Star Trek ASCII art? There's a category for that (look under the Television category). Can't get enough of Star Wars, and want some Star Wars ASCII art? There's a category for that (look under the Movies category). Want some sports related ASCII art? There's a category for that.

If you can't find what you're looking for there, you might want to try to create ASCII art from a real image. Visit the ASCII Art Generator website. There, you can upload an image to be converted into ASCII art. Simple images without a lot of detail tend to work best, and the simpler the better. I visited the website and converted a picture of Texstar into ASCII art.

This ...

... became this ...

Don't hesitate to play with the settings on the website. Since we're using cowsay, we will need to create a monochrome ASCII art image. Moving the "whitepoint" slider towards the left makes the generated image lighter, and moving the "blackpoint" slider towards the right makes the generated image darker. I also found that having the top slider more towards the "Shading" end produces better ASCII art images for use with cowsay. After you've adjusted the settings, just click the "Regenerate" button to redraw your image. Don't worry ... the ASCII Art Generator runs right in your browser, and none of the images are stored on their server. Not even the images that you "upload." Once your ASCII art image is created to your satisfaction, simply copy the ASCII text from the website and paste it into your text editor.

If you're so inclined (and if you have the time), you can even create your own ASCII art from scratch. Just be sure to do it in a simple text editor, using a monospaced font.

Note that when you "grab" ASCII art images, you will have to copy the text, instead of right clicking and choosing "Save image as..." as you would do with "real" images, like with JPG and PNG files. Just save your ASCII art images as plain text files -- for now.

Next, as root, open one of the installed cow files on your computer. Don't worry ... if you installed cowsay from the PCLinuxOS repos, and they will be in the /usr/share/cows directory. Below is what the kitty.cow file looks like in a simple ASCII text editor.

Simply replace the "text" between the second $thoughts and the EOC line at the end with your ASCII art that you copied from the above website. You'll get a much better feel for what your ASCII art image will look like if you a) use a plain, ordinary text editor (Gedit, Kate, Mousepad, Leafpad, Geany, etc.) and b) if you use a monospaced font to display your text files (such as Monospace, Liberation Mono, Courier New, etc.). DO NOT use LibreOffice or any other word processor, such as Abiword or the one in the Calligra office suite, to edit or save your ASCII art image text!

Now, just resave your cow file, with its own unique name. For the image of Texstar, I called the file texstar.cow. Here's how the texstar.cow file appears in my text editor, Mousepad:

Here is how the texstar.cow file appears in my terminal:


See? Whoever said that working in a terminal session was boring never had cowsay and fortune-mod installed on their computer. Plus, with zen-subz combination of the two programs into one script, it combines both fun programs into a really fun time.

Previous Page              Top              Next Page