[comp.unix.questions] PS1 to show working dir

johnk@auscso.UUCP (John Knutson) (11/18/87)

It is possible, but since i don't know what machine or os or version you're
running on (the only article i saw was a reply with NO included lines).
Here, (ksh on sysv.3) PS1="`pwd` !$"; export PS1  will do the trick.  will look
like: /usr2/auug/johnk 5$ Pnews ; or whatever.  I could even do something
like:
PS1="`cat $HOME/.signature` What?? "
and that would work, but it would be quite cumbersome and why would i want
my signature file in my prompt anyway?? :-)
~.
-- 
John Knutson   {ihnp4,allegra,ut-sally}!ut-ngp!auscso!johnk
	Living is easy with eyes closed, misunderstanding all you see
	Communicating, like in the good ol' days.
Disclaimer:  Don't look at me, I don't even work here!

wnp@killer.UUCP (11/19/87)

In article <735@auscso.UUCP> johnk@auscso.UUCP (John Knutson) writes:
>It is possible, but since i don't know what machine or os or version you're
>running on (the only article i saw was a reply with NO included lines).
>Here, (ksh on sysv.3) PS1="`pwd` !$"; export PS1  will do the trick. will look
>like: /usr2/auug/johnk 5$ Pnews ; or whatever.  I could even do something
>like:
>PS1="`cat $HOME/.signature` What?? "
> ...

Problem with that is that it sets the prompt to whatever the CWD was when you
typed PS1="`pwd`...". In other words, it does not get updated every time you 
cd to a different directory.

Some versions of the Bourne shell maintain a variable $PWD which gets updated
every time you cd, and if that's true for your version of the shell, 

	PS1="\$PWD >";export PS1

will create a prompt that is updated every time you cd.

I have seen other variable names uses for this purpose; to find out what
variable tu use on your system type "set", then "cd ..", then "set" again, and
check which variables reflect this change in your current directory. One other
name I've seen used for this is $CWD, or $cwd on BSD systems.

Wolf Paul
ihnp4!killer!dcs!wnp

tbm@anuck.UUCP (t.b.merrick) (11/29/87)

> Here, (ksh on sysv.3) PS1="`pwd` !$"; export PS1  will do the trick.  
> ...
> PS1="`cat $HOME/.signature` What?? "

It seems quicker to use PS1='$PWD' ; export PS1.  You don't get the
command number tho as given above.  It seems to me that not all versions
of KSH  accept this construction.  Note, the single quotes are needed to
delay evaluation so you don't just get the directory in which the statement
is executed, instead of the target directory.

Tom Merrick ATT BTL Andover, MA.