Getting UNIX prompt to display current directory
ilan343 at violet.berkeley.edu
ilan343 at violet.berkeley.edu
Sun Mar 19 09:35:21 AEST 1989
In article <5582 at ncsugn.ncsu.edu> fristens at ncsugn.ncsu.edu (Brian Fristensky) writes:
>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
>guess is that it would involve getting pwd output into the shell variable
>$PS1, but that would require somehow getting pwd to execute after each
>command you type.
I use an idea plagiarized from a contribution by Daniel Bauer to the
Wizard's Grabbag (UnixWorld-August 1988). It creates a function to
replace "cd". Everytime you change directory, PS1 is redefined.
It also changes the prompt whenever a sub-shell is open, keeping count
of what level your are.
More information about the Comp.unix.questions
mailing list