Path: utzoo!mnetor!uunet!husc6!bbn!diamond.bbn.com!mlandau From: mlandau@bbn.com (Matt Landau) Newsgroups: comp.unix.wizards Subject: Re: How to have PS1 evaluated after each "cd" Message-ID: <10456@jade.BBN.COM> Date: 31 Dec 87 20:29:00 GMT References: <574@ambush.UUCP> <1876@netsys.UUCP> <1374@bucsb.UUCP> Reply-To: mlandau@bbn.com (Matt Landau) Organization: BBN Laboratories Incorporated, Cambridge, MA Lines: 27 Summary: In tcsh you can use precmd In comp.unix.wizards (<1374@bucsb.UUCP>), eap@bucsb.UUCP (Eric Pearce) writes: >I've been using this for quite a while under csh/tcsh (I did not write >it myself) > > [Demo of using alias to change prompt on cd, pushd, etc.] Well, if you can run tcsh, you can use the precmd alias to have your prompt set each time it is printed. I use to following on my Suns: if ($TERM == "sun" && `tty` != "/dev/console" && ! $?EMACSEDIT_TTY) then set prompt = "%S$prompt%s" alias precmd echo -n '^[]l ${root}${HOST}:${cwd}^[\\ ' else if ($TERM =~ xterm* && ! $?EMACSEDIT_TTY) then alias precmd echo -n '^[]l ${root}${HOST}:${cwd}^[ ' endif $HOST and $cwd are maintained by tcsh, and $root is set by a simple test to "#" if I have superuser privileges in this shell. The escape sequences set the window banner for each shelltool or xterm window so that it contains the hostname and working directory, in a form like "diamond:/usr/local/src". Since this precmd uses only shell variables and builtins, it's acutally fast enough that you can reset the prompt after every command without feeling any performance penalty. -- Matt Landau Waiting for a flash of enlightenment mlandau@bbn.com in all this blood and thunder