Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!unmvax!pprg.unm.edu!hc!lll-winken!uunet!mcvax!hp4nl!botter!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.questions Subject: Re: Getting UNIX prompt to display current directory Keywords: UNIX prompt directories pwd Message-ID: <2187@solo11.cs.vu.nl> Date: 21 Mar 89 02:16:53 GMT References: <5582@ncsugn.ncsu.edu> Organization: V.U. Informatica, Amsterdam, the Netherlands Lines: 40 fristens@ncsugn.ncsu.edu (Brian Fristensky) writes: \... it would involve getting pwd output into the shell variable \$PS1, ... It seems you're using /bin/sh (or ksh). The following will work: Solution 1 (put the following in a script `c'). ------------------------------ #! /bin/sh # # c: a script to change the prompt of the parent to the new working # directory # to put in $HOME/.profile: # # PARENT=$$ # export PARENT # trap 'DIR=`cat $HOME/.dir`; cd $DIR; PS1="$DIR> "' 5 cd $1 pwd > $HOME/.dir exec kill -5 $PARENT ------------------------------ Solution 2 (if your sh has shell functions). ------------------------------ c() # you might not be able to name this function `cd' { cd $1 + PS1="`pwd`> " } ------------------------------ Solution 3 (if your sh has both shell functions and $PWD). ------------------------------ Change the line indicated with `+' to PS1="$PWD> " -- Modeless editors and strong typing: |Maarten Litmaath @ VU Amsterdam: both for people with weak memories. |maart@cs.vu.nl, mcvax!botter!maart