[comp.unix.sysv386] Fortune Cookie Prompt

orville@weyrich.UUCP (Orville R. Weyrich) (06/10/91)

I would like to set up a fortune-cookie type of program which displays
a new randomly selected message each time my shell prompts me. It seems
that I saw some description in a OLD FAQ list about how to include the
"working directory" in the prompt, but I have lost that FAQ list.

I understand that the solution to my problem is going to be system-dependent.

My system is Microport Unix System V/386 revision 3. I normally use the Bourne
shell, but if it would help, could change to the csh or ksh distributed with
my system.

As a last resort, I have considered placing a directory at the beginning of
my search path which redefines all my system and user commands to invoke the
normal command followed by the cookie program. This solution is not very 
elegant, will mess up i/o redirection, would produce multiple cookies when
I use pipes, and is possibly a security hole.

[I can minimize the problem with the i/o redirection by having the cookie
program use stderr].

By the way, I'd like to do the same thing with MS-DOS. Any suggestions?
[I used to know how to do it with CP/M, but have put my CP/M documentation into
deep storage].

--------------------------------------           ******************************
Orville R. Weyrich, Jr., Ph.D.                   Certified Systems Professional
Internet: orville%weyrich@uunet.uu.net             Weyrich Computer Consulting
Voice:    (602) 391-0821                         POB 5782, Scottsdale, AZ 85261
Fax:      (602) 391-0023                              (Yes! I'm available)
--------------------------------------           ******************************

sharman@Software.Mitel.COM (Richard Sharman) (06/17/91)

In article <1991Jun10.003223.3384@weyrich.UUCP> orville@weyrich.UUCP (Orville R. Weyrich) writes:

   I would like to set up a fortune-cookie type of program which displays
   a new randomly selected message each time my shell prompts me. It seems
   that I saw some description in a OLD FAQ list about how to include the
   "working directory" in the prompt, but I have lost that FAQ list.


If you can get hold of the tcsh shell, the alias precmd can be set a
command which gets run before the prompt.  Beware, though, if you set
it to something erroneous you may have to hangup to recover.


% alias precmd /usr/games/fortune
"My weight is perfect for my height -- which varies"
% pwd
/auto/home/tools/sharman
The human mind treats a new idea the way the body treats a strange
protein -- it rejects it.
		-- P. Medawar
% date
Sun Jun 16 22:28:17 EDT 1991
Washington [D.C.] is a city of Southern efficiency and Northern charm.
		-- John F. Kennedy
%