Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!munnari!otc!metro!basser!elecvax!neilb
From: neilb@elecvax.eecs.unsw.oz (Neil F. Brown)
Newsgroups: comp.unix.wizards
Subject: Re: The whole prompt string thing (was: PS1 and the bourne shell...)
Message-ID: <3855@elecvax.eecs.unsw.oz>
Date: Fri, 4-Dec-87 19:40:11 EST
Article-I.D.: elecvax.3855
Posted: Fri Dec  4 19:40:11 1987
Date-Received: Sat, 12-Dec-87 12:38:44 EST
References: <279@caus-dp.UUCP> <1311@puff.wisc.edu>
Organization: EE and CS, Uni of NSW, Sydney, Australia
Lines: 34
Summary: Yes, there IS an answer (but I dont think you're going to like it)

I, too, once believed that you couldn't do clever things in a pre SysV shell
like change the prompt when you changed directory.
Then someone told me you could. I thought about it and realised he was right.
Its slow, its not real nice, but it does work.

For instance:

in your .profile put the lines

PARENT=$$
export PARENT
trap 'DIR=`cat $HOME/.dir` ; cd $DIR ; PS1="$DIR :- "' 6

then in a directory somewhere in your path but the file

ch:
	cd $1
	pwd > $HOME/.dir
	kill -6 $PARENT

and make it execuatable

Now to change directory, type
	ch newdir
And your prompt will change along with your directory.

You can even use this approach to create and manipulate directory stacks,
though I'll leave the details of that to the interested reader.

Ofcourse a better solution it to get a newer shell, though thats
easier said than done.
Hopefully one will appear in a sources news group somtime.

NeilBrown