Getting UNIX prompt to display current directory

News Service news at lindy.Stanford.EDU
Sun Mar 19 10:24:29 AEST 1989


) In MS-DOS there is a very easy way to get the current directory displayed as
) part of the prompt  (prompt $p).  In UNIX, there is certainly no
) straightforward way to do this.  Can anyone think of a tricky way? 

My favorite answer to this perennial question:

PS1=.

"I tried that and it didn't work ..."

Call for votes for comp.unix.newusers, anyone?


In shells that allow aliases or functions, the usual trick is to
redefine the commands that let you change your current directory
(cd, pushd, popd, ...) so they also change $PS1 or $prompt or
whatever.  If I'm not mistaken, ksh also allows a better way to do
this.  In any case, a year's worth of archive of this newsgroup would
doubtless turn up a "wealth" of responses, for any given year.



More information about the Comp.unix.questions mailing list