Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!rutgers!cmcl2!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.unix.questions Subject: Re: Bourne Shell Question? Message-ID: <9562@smoke.BRL.MIL> Date: 1 Feb 89 23:14:36 GMT References: <8517@dasys1.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 28 In article <8517@dasys1.UUCP> dap9702@dasys1.UUCP (Dan Powers) writes: > Does anyone know how to get a prompt in Bourne Shell that contains the >current working directory (pwd). Not all Bourne shells have sufficient capabilities to do this. I think for the Korn shell one would use "alias" in a manner similar to your Cshell example. On UNIX System V Release 2 and later shells (i.e. those supporting shell functions), you can define a function (unfortunately not called "cd"; use "ch" instead, for example) that sets the shell variable PS1 appropriately as it does the "cd"). For 8th or 9th Edition UNIX shells and the BRL Bourne shell, you can use the "builtin" builtin to redefine "cd", for example: cd(){ if [ $# -lt 1 ] then builtin cd else builtin cd "$1" fi if [ `pwd` = "$HOME" ] then PS1='$ ' else PS1=`echo "$CWD" | sed "s!^$HOME!~!"`'$ ' fi } (My actual "cd" definition is MUCH more elaborate than this.) You can adapt the above to SVR2 shells by renaming the function and removing the "builtin" keywords.