current pwd in prompt

bob desinger bd at hpsemc.HP.COM
Wed Mar 2 16:48:32 AEST 1988


Geoffrey R. Walton (geoff at ncr-sd.SanDiego.NCR.COM) writes:
>    set prompt="\!:`uuname -l`:[`pwd`] "
>    alias pushd	'pushd \!* ; set prompt="\\!:`uuname -l`:[`pwd`] "'
>    alias popd	'popd ; set prompt="\\!:`uuname -l`:[`pwd`] "'
>    alias cd	'cd \!* ; set prompt="\\!:`uuname -l`:[`pwd`] "'

To wring every drop of speed out of it, set an envariable called, say,
$host to the value of `uuname -l` in your .login or .cshrc file.  Then
use $host in your $prompt.  (This won't work if your super-user
changes your hostname every few minutes.)

To answer the original question about doing similar things in ksh, I
can send default .profile and .kshrc files that do exactly that.  My
prompt contains the basename of the current directory and a reminder
of the host I'm on.  The actual basename program was too slow, so I
use a ksh built-in to do it.  The real work is done in one line:

	PS1="${host}_${PWD##*/}/ "

This makes my prompts look like (when I'm in, say, /usr/spool/uucp):

	a_uucp/

bob desinger	bd%hpsemc at hplabs.HP.COM		uunet!hpda!hpsemc!bd



More information about the Comp.unix.questions mailing list