*BSD News Article 82383


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.ecn.uoknor.edu!feed1.news.erols.com!howland.erols.net!news.mathworks.com!news.PBI.net!ns2.mainstreet.net!news.roble.com!not-for-mail
From: marquis@roble.com (Roger Marquis)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: Prompt won't show `pwd`
Date: 6 Nov 1996 01:45:22 GMT
Organization: Roble Systems (http://www.roble.com)
Lines: 34
Message-ID: <55oqji$7es@alba.roble.com>
References: <327D7D20.1467@auburn.campus.mci.net>
NNTP-Posting-Host: ns.roble.com
X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]

Anthony Jenkins (ajenkins@auburn.campus.mci.net) wrote:
>How do I get my shell prompt (csh or sh) to show the current working
>directory every time it is printed?  Setting prompt to "`pwd`#" only
>sets the prompt to the directory I am in when I issue the set command;
>cd-ing to another directory doesn't affect the prompt.  Thanks in
>advance.

Try this in your ~/.cshrc:

#-------------------------------------------------------------------------------
   if (! $?tcsh ) then
      set filec
      alias setprompt 'set prompt="`/usr/ucb/whoami`"@"`hostname`":"`dirs`>"'
      alias cd 'cd \!*;setprompt'
      setprompt
   else
      bindkey -v
      set autolist
      set autoexpand
      set correct
      if ( "$TERM" == "sun" || "$TERM" == "sun-cmd" || $?win ) then
         set prompt="[%\!:%?]%n@%m:%~> "
      else
         set prompt="%{^[[31m%}[%\!:%?]%{^[[33m%}%n@%m:%{^[[0;35m%}%~>%{^[[0;37m%}
"
      endif
   endif
#-------------------------------------------------------------------------------

It should give you a prompt with 1) userid, 2) hostname, and 3) the
current directory.  In tcsh it will also prepend the current command
number and the last program's exit status.

Roger Marquis