Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: zsh - new user with questions



"Stephen Riehm" wrote:
>      extreme short cuts. ie: with tcsh's enhanced completions, to complete
> the file named: ReadMe.First
>      all I would type id: r.f<tab> - is there a way to do this sort of
> thing in zsh?

You can write your own function.  See Functions/multicomp in the
source distribution for examples.  If you really can't type uppercase
characters, you're going to have to redo the globbing there so
that every lowercase character becomes e.g. [rR], then you'll
need to handle .'s in the way /'s are handled there.  Ignoring case
may happen one day, but I doubt there's ever going to be a built-in
way of saying 'look and see if there are any characters preceeding a
dot to be added earlier on in the completion'.  Maybe you would be
interested in the options automenu and menucomplete.  You'll have
to find the shift key, however.  Do 'setopt automenu', type R,
and hit tab until it works.

>      - I tried use ls ***/*(/l2) to find all the empty directories in a
> tree, but it didn't work, instead it counted the number
>      of directories in each directory (I think, I wasn't quite sure what it
> was doing)

You need ls -d, and it doesn't just show empty directories since the link
count doesn't get incremented for plain files.  I don't think you
can do it in one glob expression.  Best I can think of (using your
glob to prune out non-terminal directories) is

for f in ***/*(/l2); do foo=($f/*(N)); [[ -z $foo ]] && print $f; done

*(N) turns on nullglob, i.e. $foo is empty if there was nothing in $f.

> Is it possible to make
>      all cd's happen in relation to your logical position?

This should happen with the option CHASE_LINKS unset.

> Is it possible to say that it should complete
> non-hidden directories, unless the text typed indicates
>      otherwise, ie: if I type "cd <tab>", I get a list of all the normal
> directories, but if I then type .<tab> it should use the
>      . and show me all the directories beginning with .

With 3.1.4, -/ is a better way of doing it than -g; this will work as you
want.  For more general things like that, you probably need to wait
until particular completions can be bound to particular keys, which
should happen some time.

-- 
Peter Stephenson <pws@xxxxxx>       Tel: +39 50 844536
WWW:  http://www.ifh.de/~pws/
Gruppo Teorico, Dipartimento di Fisica
Piazza Torricelli 2, 56100 Pisa, Italy



Messages sorted by: Reverse Date, Date, Thread, Author