Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!agate!violet.berkeley.edu!ilan343 From: ilan343@violet.berkeley.edu Newsgroups: comp.unix.questions Subject: Re: Getting UNIX prompt to display current directory Keywords: UNIX prompt directories pwd Message-ID: <21813@agate.BERKELEY.EDU> Date: 18 Mar 89 23:35:21 GMT References: <5582@ncsugn.ncsu.edu> Sender: usenet@agate.BERKELEY.EDU Organization: University of California, Berkeley Lines: 13 In article <5582@ncsugn.ncsu.edu> fristens@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.