Printing Working Directory in CSH (or SH for that matter)

Steven M. List itkin at mrspoc.Transact.COM
Tue Apr 30 06:15:22 AEST 1991


root at swatty.UUCP (Superuser) writes:

>Does anybody know how to set the prompt in csh so that the current directory
>name (eg., /usr/lib/uucp) is printed (kind of like a dos $p$g), also can this
>be done is sh...

Here's how I do it - works quite nicely, and the delay when changing 
directories is minimal:

    set UID = `id | sed 's/uid=\([0-9][0-9]*\).*/\1/'`
    if ($UID == 0) then
        set uname = "`uname -n`-ROOT"
    else
        set uname = `uname -n`
    endif

    alias cd 'chdir \!* ; set prompt = "-${uname}:`pwd`-\! > "'
    cd .

note that the final "cd ." is executed in .cshrc when the alias is set
up so that the prompt will be set the first time.
-- 
 +----------------------------------------------------------------------------+
 :                Steven List @ Transact Software, Inc. :^>~                  :
 :           Chairman, Unify User Group of Northern California                :
 :                         itkin at Transact.COM                                 :



More information about the Comp.unix.xenix.sco mailing list