Path: utzoo!utgpu!water!watmath!clyde!ho95e!wcs From: wcs@ho95e.ATT.COM (Bill.Stewart) Newsgroups: comp.unix.questions Subject: Re: current pwd in prompt Summary: PS1='$PWD ' ## Note single quotes Message-ID: <1981@ho95e.ATT.COM> Date: 14 Feb 88 01:24:15 GMT References: <11656@brl-adm.ARPA> <253@icus.UUCP> Reply-To: wcs@ho95e.UUCP (46323-Bill.Stewart,2G218,x0705,) Organization: AT&T Bell Labs 46133, Holmdel, NJ Lines: 16 :In article <11656@brl-adm.ARPA> Mensing.HENR801c@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