Get Your Daily Dose of Trivia





Get Your Daily Dose of Trivia

figs/beginner.gif figs/hack6.gif

Brighten your day with some terminal eye candy.

As the saying goes, all work and no play makes Jack a dull boy. But what's a poor Jack or Jill to do if your days include spending inordinate amounts of time in front of a computer screen? Well, you could head over to http://www.thinkgeek.net/ to stock up on cube goodies and caffeine. Or, you could take advantage of some of the entertainments built into your operating system.

1 A Fortune a Day

Let's start by configuring some terminal eye candy. Does your system quote you a cheery, witty, or downright strange bit of wisdom every time you log into your terminal? If so, you're receiving a fortune:

login: dru

Password:

Last login: Thu Nov 27 10:10:16 on ttyv7



"You can't have everything. Where would you put it?"

                -- Steven Wright

If you're not receiving a fortune, as the superuser type /stand/sysinstall. Choose Configure, then Distributions, and select games with your spacebar. Press Tab to select OK, then exit out of sysinstall when it is finished.

Then, look for the line that runs /usr/games/fortune in your ~/.cshrc file:

% grep fortune ~/.cshrc

/usr/games/fortune

If for some reason it isn't there, add it:

% echo '/usr/games/fortune' >> ~/.cshrc

Don't forget to use both greater-than signs; you don't want to erase the contents of your .cshrc file! To test your change, use the source shell command, which re-executes the contents of the file. This can come in handy if you've updated an alias and want to take advantage of it immediately:

% source ~/.cshrc

Indifference will be the downfall of mankind, but who cares?

If you'd also like to receive a fortune when you log out of your terminal, add this line to the end of your .logout file. If you don't have one, and there isn't one by default, you can create it and add this line in one step:

% echo '/usr/games/fortune' > ~/.logout

Note that this time I used only one greater-than sign, as I was creating the file from scratch. If the file already exists, use two greater-than signs to append your new line to the end of the existing file.

Believe it or not, fortune comes with switches, some of which are more amusing than others. I'll leave it to you to peruse man fortune.

2 Pursuing Trivia

I'm a trivia buff, so I love using the calendar command. Contrary to logic, typing calendar won't show me this month's calendar (that's the job of cal). However, I will get an instant dose of trivia, related to the current date:

% calendar

Nov 27         Alfred Nobel establishes Nobel Prize, 1895

Nov 27         Friction match invented, England, 1826

Nov 27         Hoosac Railroad Tunnel completed, 1873, in NW Massachusetts

Nov 28         Independence Day in Albania and Mauritania

Nov 28         Independence from Spain in Panama

Nov 28         Proclamation of the Republic in Chad

Nov 27         Jimi Hendrix (Johnny Allen Hendrix) is born in Seattle, 1942

Cool. I had forgotten it was the anniversary of the Hoosac tunnel, an event that put my hometown on the map.

It's an easy matter to automate the output provided by calendar. If you want to see your trivia when you log in or log out, simply add a line to your .cshrc or .logout file. Because the line you add is really just a path to the program, use the output of the which command to add that line for you:

% echo `which calendar` >> .cshrc

Again, don't forget to append with >>, or have noclobber set in your .cshrc file [Hack #2].

3 Sundry Amusements

Of course, there are several other date and time related mini-hacks at your disposal. Here are two you might enjoy.

3.1 The current time

Ever wonder what time it is while you're working on the terminal? Sure, you could use date, but the output is so small and boring. Try this the next time you want to know what time it is:

% grdc

Whoa, you can see that one from across the room. That's not a bad idea if you want to send your cubicle buddy a hint.

I've been known to add /usr/games/grdc to my ~/.logout. When I log out, my terminal displays the time until I press Ctrl-c and log in again. That's sort of a built-in password protected screen saver for the terminal.

3.2 The phase of the moon

Have you ever read man pom? It has one of the more useful descriptions I've seen:

The pom utility displays the current phase of the moon. Useful for selecting software completion target dates and predicting managerial behavior.

Sounds like Dilbert had a hand in that one. If I add the line /usr/games/pom to my ~/.cshrc, I'll learn a bit about astronomy when I log in:

% pom

The Moon is Waxing Gibbous (53% of Full)

There's a one-liner to promote water cooler conversation.

4 Adding Some Color to Your Terminal

Have you ever tried this command?

% vidcontrol show         



0                  8 grey               

1 blue             9 lightblue

2 green           10 lightgreen

3 cyan            11 lightcyan

4 red             12 lightred

5 magenta         13 lightmagenta

6 brown           14 yellow

7 white           15 lightwhite

Gee, that reminds me of my old DOS days when I discovered ansi.sys. Yes, your terminal is capable of color and you're looking at your possible color schemes! (It likely looks much more exciting on your terminal, since it's not in color in this book.)

If you see some colors that appeal to you, add them to your terminal. For example, this command will set the foreground color to yellow and the background color as blue:

% vidcontrol yellow blue

Note that you can use only colors 1 through 7 as background colors; you'll receive a syntax error if you try to use colors 8-15 in your background. Try out the various combinations until you find one that appeals to your sense of taste. You can even add a border if you like:

% vidcontrol -b red

These settings affect only your own terminal. If you want, add the desired vidcontrol lines to your ~/.cshrc file so your settings are available when you log into your terminal.

If you have problems finding your cursor, try:

% vidcontrol -c blink

or:

% vidcontrol -c destructive

Changing the cursor affects all virtual terminals on the system. If other users complain about your improvement, this will bring things back to normal:

% vidcontrol -c normal

5 See Also

  • man fortune

  • man calendar

  • man vidcontrol

  • The games packages, in NetBSD and OpenBSD


     Python   SQL   Java   php   Perl 
     game development   web development   internet   *nix   graphics   hardware 
     telecommunications   C++ 
     Flash   Active Directory   Windows