current pwd in prompt

Bill.Stewart wcs at ho95e.ATT.COM
Sun Feb 14 11:24:15 AEST 1988


:In article <11656 at brl-adm.ARPA> Mensing.HENR801c at Xerox.COM writes:
:|>Can anyone explain to me how to get my prompt to be the current directory? I
:|>have tried several methods without any success. It seems that no matter what
:|>method I try, the prompt is evaluated once and never changes.
	Korn Shell keeps the current directory in a variable $PWD,
	which is updated every time you change directory.
	In the current and current-1 versions of ksh, if the PS1
	variable contains a shell variable, it will be evaluated every
	time PS1 is displayed as a prompt.  The trick is to set
		PS1='$PWD '	## note single quotes
	so PS1 contains the string $PWD, not the value $PWD had when
	you set it (which you get with PS1="$PWD ".)  You can also use
	this with other shell variables, such as $? and $SECONDS.
-- 
#				Thanks;
# Bill Stewart, AT&T Bell Labs 2G218, Holmdel NJ 1-201-949-0705 ihnp4!ho95c!wcs



More information about the Comp.unix.questions mailing list