*BSD News Article 82536


Return to BSD News archive

#! rnews 1820 bsd
Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.mel.connect.com.au!munnari.OZ.AU!news.Hawaii.Edu!news.uoregon.edu!news.texoma.com!www.nntp.primenet.com!nntp.primenet.com!cs.utexas.edu!news.cs.utah.edu!cc.usu.edu!kurto
From: kurto@cc.usu.edu (Kurt Olsen)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: Prompt won't show `pwd`
Message-ID: <1996Nov5.145304.88491@cc.usu.edu>
Date: 5 Nov 96 14:53:04 MDT
References: <327D7D20.1467@auburn.campus.mci.net>
Organization: Utah State University
Lines: 34

In article <327D7D20.1467@auburn.campus.mci.net>, Anthony Jenkins <ajenkins@auburn.campus.mci.net> writes:
> 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.
> 
> Anthony

Well, this is what I do:

if ( $?DISPLAY ) then
  alias showpath 'echo -n "^[]2;`hostname -s` - `pwd | sed -esl/usr/user/kurtol
kurtol`^G"'
else
  alias showpath 'set prompt="`hostname -s`:`pwd | sed -esl/usr/user/kurtolkurtol`> "'
endif
#
showpath
alias cd "cd \!*; showpath"
alias pushd "pushd \!*; showpath"
alias popd "popd \!*; showpath"
alias telnet "telnet \!*; showpath"

All that's in my .login.  The first showpath alias is for xterms (it's
probably missing some control codes) and it set's my host and path to
the title of the xterm.  The second is when I'm, not on an xterm and
it sets my prompt.  Whenever I use cd, pushd, popd, telnet it does
the command and executes showpath.

Some shells have a variably that will automatically do this for you.
-- 
Kurt Olsen (kurto@cc.usu.edu)
<a href="http://www.mcs.usu.edu/~kurto/">Me & my Atari Lynx</a> archive.