* 'cd -'
@ 1991-12-17 8:15 Paul D. Swasey
0 siblings, 0 replies; only message in thread
From: Paul D. Swasey @ 1991-12-17 8:15 UTC (permalink / raw)
To: rc
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
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1991-12-17 8:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1991-12-17 8:15 'cd -' Paul D. Swasey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).