[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "cdpath" searching, and pushd/popd too



> Myself, I have become addicted to pushd and popd, but I will not
> suggest adding them to es.

Likewise.  *ALL* of my change-dir commands do a "pushd"-equivalent.
I use a "z" command instead of "cd" and it *always* pushes the directory.

> Indeed I find them somewhat painful to
> use, even though I use them frequently:  Getting back to a particular
> directory requires a `dirs' followed by careful counting to figure out
> which number to give to `pushd'.

Counting!?  Boy am I glad I never had to use csh and get my brain
damaged that way.  :-).  [I used ksh for seven years, and got my
brain damaged *that* way.]  Anyway, let a little bit of es code do
that search!

I have a "zq" command which takes a fragment of a directory pathname,
and does the chdir, back to the first stack directory that matches your
fragment.  It's much easier to use, since I usually either remember a
unique piece of the directory name, or I can easily see it from a "zc"
(like "dirs" but one per line) listing.

> This is still experimental, but I would like to know what others think
> of the idea and what other solutions to the same problem people have
> come up with.

Since mine happens all automatically, without premeditation, whenever
I move around, and it's still very easy to get back to any directory
I've been in that session, I find it very easy to use.  If there's
interest, I may find the time to sanitize & share the es code that does
this.  It's pretty easy to do, though -- much easier in es than it
was in [gasp] ksh.

> Oh, there is one problem with this, as well as with the classical
> pushd/popd, and with back to:  We have a system where lots of file
> system are NFS mounted using the automounter.  Now trying to cd back
> to a directory that I didn't visit for a while can easily fail, as I
> haven't save the version of the path that will trigger the automounter
> to remount the volume.  Any good solutions for that one?

I don't understand the problem.  Nearly every directory I use is also
automounted, and I never run into this.  Maybe it's because I always save
the directories' full pathnames?

The transcript below is a wee bit confusing, because "zc" prints out the
directory list in the form of "z" commands, to make it easier to pick/put
them with a mouse; and because if the directory is under one of my most-
commonly-used variables, I keep it condensed in '$varname' form.

: /tmp ; z /usr/sbin
: /usr/sbin ; z /etc
: /etc ; z $wx
: $wx ; zc
z $wx
z /etc
z /usr/sbin
z /tmp
: $wx ; zq r/s
z /usr/sbin
: /usr/sbin ; zc
z /usr/sbin
z $wx
z /etc
z /tmp
: /usr/sbin ;

Anyway, hope this gives you some ideas.  Let me know if it'd be worth the
effort to post "z" and friends.
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Doug.Landauer@sun.com | "Wow, look at the grass stains on my skin.  I say, if
 SUNW[STE]->SunPro::  | your knees aren't green by the end of the day, you
  Languages.IPE(C++); | ought to seriously re-examine your life." -- Calvin