prompt question

Bob Sutterfield bob at MorningStar.Com
Sat Feb 9 02:09:11 AEST 1991


I like to have my pwd in my xterm window's title stripe, and the time
of day in the shell prompt.  I also like to have the prompt in
inverse-video if I happen to be doing rootly things at the moment,
just to warn me of the increased probability that I'm about to break
something.

I use cshe, a local csh variant.  %t gives the current time string and
%S/%s shift inverse/normal video, as per the termcap entry.  Most of
the prompt string substitution capabilities (or something similar) are
also available in tcsh and its descendants.  In the .cshrc excerpt
below, I've changed actual escape and bell characters into their
equivalent two-character graphic representation.  It could probably be
done prettier in csh, or cleaner in ksh functions, but you get the
idea.

#
set host=(`hostname | tr '.' ' '`)
setenv HOST $host[1]
#
# interactive shell?
if (! $?prompt) exit
#
if ($?DISPLAY) then
	alias precmd 'echo -n "^[]0;"{$HOST}":$cwd^G"'
	set prompt="%t> "
	if ($?uid) then
	    if ($uid == 0) set prompt="%S%t>%s "
	endif
else
	set prompt={$HOST}":%/> "
	if ($?uid) then
	    if ($uid == 0) set prompt={$HOST}":%S%/>%s "
	endif
endif
#



More information about the Comp.unix.misc mailing list