From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from po3.andrew.cmu.edu ([128.2.12.31]) by archone.tamu.edu with SMTP id <18888>; Tue, 17 Dec 1991 02:17:45 -0600 Received: by po3.andrew.cmu.edu (5.54/3.15) id for rc@archone.tamu.edu; Tue, 17 Dec 91 03:17:27 EST Received: via switchmail; Tue, 17 Dec 1991 03:17:25 -0500 (EST) Message-Id: Received: from peso.mdg.andrew.cmu.edu via qmail ID ; Tue, 17 Dec 1991 03:15:34 -0500 (EST) Received: from peso.mdg.andrew.cmu.edu via qmail ID ; Tue, 17 Dec 1991 03:15:26 -0500 (EST) Date: Tue, 17 Dec 1991 02:15:24 -0600 From: "Paul D. Swasey" To: rc@archone.tamu.edu Subject: 'cd -' Here is a simple way to get the effect of kshes 'cd -', it costs an extra line per cd command in your $history but it only costs one variable (the current directory cache) and one call to "pwd", when leaving the current directory (if the current directory is not $home). (it's nice for me because I do "pwd" a lot, anyway, so "cd" only has to calculate the current directory about half the time...) sample: peso ; pwd /afs/andrew.cmu.edu/system/src/contributed/niftylibs/017/util peso ; cd peso ; - cd cd /afs/andrew.cmu.edu/system/src/contributed/niftylibs/017/util peso ; tail -7 $history pwd cd cd /afs/andrew.cmu.edu/system/src/contributed/niftylibs/017/util - cd cd /afs/andrew.cmu.edu/system/src/contributed/niftylibs/017/util cd /afs/andrew.cmu.edu/usr16/ps3u tail -7 $history peso ; er, make that 2 extra lines per cd command (i forgot about the one added by -(1) ) -dave ----- fn cd { builtin cd $1 && { if (!~ $history ()) echo cd `pwd >>$history switch ($1) { case () PWD=$home case * PWD=() } } } fn pwd { if (~ $PWD ()) PWD=`{builtin pwd} echo $PWD }