Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!husc6!cmcl2!nrl-cmf!ames!necntc!ima!minya!jc
From: jc@minya.UUCP (John Chambers)
Newsgroups: comp.unix.questions,comp.unix.wizards
Subject: Re: PS1 and the bourne shell...
Message-ID: <423@minya.UUCP>
Date: Thu, 3-Dec-87 20:24:51 EST
Article-I.D.: minya.423
Posted: Thu Dec  3 20:24:51 1987
Date-Received: Tue, 8-Dec-87 05:18:06 EST
References: <279@caus-dp.UUCP> <6704@brl-smoke.ARPA> <9443@tekecs.TEK.COM>
Organization: home
Lines: 30
Summary: Well, there is a way...
Xref: mnetor comp.unix.questions:5189 comp.unix.wizards:5797

After reading all the flames about the difficulty of getting a prompt
from the Bourne shell showing the current directory, I decided to see
if it was possible.  It took about 5 minutes to determine that, yes,
it is possible, but you just might not like the solution.

Here's a script that I put into a convenient public directory under
the name "d":
	cd $d;PS1="$d: "
How do you use this little sucker?  Like this:
	d=/foo/bar . d
which puts you in /foo/bar and gets you the prompt:
	/foo/bar:
If you want to get back to your home directory, you might type:
	d= . d
and you get just a ":" prompt.  Lovely, isn't it? (;-)

Now I know that y'all would much prefer a sane syntax like that of "cd".
Well, you're just plumb out of luck, I guess.  I haven't thought it out
yet, but I believe I can make a good argument that, with the generic
Bourne shell (i.e., no aliases or functions), you can't implement the
right syntax for this operation.

If someone out there can come up with a solution, I'd like to see it.
Feel free to use my weird script if you wish; I won't consider it to
be plagiarism if a good solution is built on mine.

[This is almost as much fun as real mathematics! :-]

-- 
John Chambers <{adelie,ima,maynard,mit-eddie}!minya!{jc,root}> (617/484-6393)