Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!ncar!gatech!udel!burdvax!uucsbb!des From: des@uucsbb.UUCP (Don Shope) Newsgroups: comp.unix.questions Subject: Re: `pwd` in Shell prompt Message-ID: <299@uucsbb.UUCP> Date: 4 Apr 88 02:33:01 GMT References: <12747@brl-adm.ARPA> Reply-To: des@uucsbb.Blue Bell.UNISYS.COM (Don Shope) Organization: Unisys Unix Support Services, Blue Bell, PA Lines: 34 Summary: use a shell function to do it In article <12747@brl-adm.ARPA> H235-017%IRLEARN.BITNET@cunyvm.cuny.edu (Mark Humphrys) writes: >... >I want to get the current directory to be automatically included in the Shell >prompt. The easiest way I have found of accomplishing this is by using a Bourne shell "function". The function can be defined in your .profile. Below is a sample fragment of my .profile. The function is called "c". Use it exactly as you would use the "cd" shell command, with one addition: The syntax "c -" will switch back to the previous directory that you were in. Have fun. ----------------- cut here ----------- .profile fragment ---------- export PS1 ODIR ODIR=$HOME # function to put current directory as part of prompt. It also # "remembers" the previous directory, and goes there via "c -". This # version also displays the system name as part of the prompt, which is # useful in a networking environment. c () { if [ "$1" = "-" ]; then DIR=$ODIR else DIR=$1 fi ODIR=`pwd` cd $DIR PS1=`uuname -l`"!"`pwd`"> " } c # set the prompt now ------------------ end of cut -------------------------------------