Path: utzoo!attcan!uunet!lll-winken!ames!mailrus!iuvax!rutgers!cmcl2!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.unix.questions Subject: Re: Getting UNIX prompt to display current directory Keywords: UNIX prompt directories pwd Message-ID: <9877@smoke.BRL.MIL> Date: 19 Mar 89 06:47:07 GMT References: <5582@ncsugn.ncsu.edu> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 24 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. False. >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. False. This question arises every six months or so. If your shell supports functions or aliases, then you can replace the "cd" command with one that not only chdirs but also sets $PS1 or $prompt (depending on the type of shell). If your shell supports evaluation of the prompt string, then there is an obvious way to accomplish what you want. Finally, if you have nothing but incredibly puny shells, you can set a trap in your interactive shell that modifies the prompt string when a signal is sent by a "cd"-like executable binary or shell script. Depending on the shell, you may have to use some command other than "cd" when changing working directories in order for the kludgery to work.