[net.unix-wizards] csh: pre-prompt execution

dmy (01/07/83)

I too want csh to "do something" just prior to each prompt.
I'm trying to hack csh to do this (if anyone knows how to do it without
modifying the code, please let me know).
I simply check, at the point just prior to printing the prompt, for a
shell variable called "preprompt", and if it is non-null, execute it as a
command (e.g. using "system" or "execl" and "/bin/sh" or OTHERSHELL).
However, I don't (yet) understand csh's way of redirecting in/output, so I've
only been partly successful.  Does anyone know the easiest way to successfully
fork/vfork a process out of csh?  I.e. is there some single routine I can call
at just the right moment that resets the redirection?  I would like to see the
output of a simple command ...  Thanks.

--dmy--

fred.umcp-cs@UDel-Relay (03/04/83)

From:  Fred Blonder <fred.umcp-cs@UDel-Relay>

From: hplabs!hao!seismo!dmy@UCB-C70
	
	I too want csh to "do something" just prior to each prompt. . . .

How about evaluting the $prompt string each time csh wants to generate a
prompt? That way you could generate your own wierd and varying prompts in
addition to executing commands.

guy (03/31/83)

A version of the Bourne shell done at the Naval Surface Weapons Center
does exactly that (in addition to having a history and alias mechanism);
it runs macro() on the PS1 string before printing it.  That way, you can
set PS1 to '$CWD >' to have the current working directory printed with
the prompt (they added the CWD variable), or '`foobar` --' to run the
"foobar" command and substitute its output into the prompt, or...

					Guy Harris
					RLG Corporation
					{seismo|mcnc|we13}!rlgvax!guy