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

Re: globbing



[Please, do not send private replies to public mails unless specifically asked. Besides, others may definitely be of more help here than me :-)]

Will Yardley wrote:
Borsenkow Andrej wrote:

in bash if it hit % cd /home/* and hit tab, it just sits there (although
i can tab complete other stuff)


Can you be more precise? You want complete glob patterns but do not want to
see completion list? You do not want to see completion listing always or
only in case of completing patterns?


i don't want to tab complete them at all in that particular case... ie i'd
like to expand individual filenames but i'd like it to just act like bash and
sit there when i type cd /home/*<tab> or whatever.  i may be explaining
myself wrong which might be resulting in some confusion, but that's the best
way i know how to explain it.  i still want the * to represent a wildcard; i
just don't want to see a list of 5 billion files at once, and if i type:
mv ju*<tab> i don't want to have the command line turn into:
mv junk1 junk2 junk2

i wouldn't even mind having something like auto_list or bash_auto_list for
it; i just don't want all possible matches for * to show up on the command
line.  if i accidentally type tab when trying to do /home/*/something it's
very annoying to have the whole command line fill up with every possible
match.  this has happened to me on a number of occasions.

is there an old skool way to do this? i will brave the new styles if i must
but i am still a bit fearful.  i know 4.02 is faster than 4.01 with that, but
a lot of my machines for work are much older versions of zsh.


Of course. Use complete-word instead of expand-or-complete:

bindkey '^I' complete-word

It will totally ignore any patterns and try to complete "as is". But note that new completion gives you choices between completion, matching and expansion and you can select the order in whch it happens and and and ...


But I realized that listing is not controlled by style. How weird.
Actually, according to documentation, the

zstyle ':completion::match:*' menu off
must work but does not.

yeah that doesn't work either.


i think the second question has been brought up before, but is there a
way to do: % cd /usr/l<tab>bin and have that complete to /usr/local/bin
as in bash (without putting a space after /usr?  i do have
complete_in_word set, but that's not exactly the same thing...

Why do you want to do it "bash style" with zsh? E.g. using zsh it is much
better to do

ls /u/l/bTA

that is cool but not at all what i was trying to accomplish...
the whole reason i'm changing it in the middle of the word is because
i made a mistake.  ie

cd /usr/bi (ooops)
cd /usr/l<tab>/bi

in bash this expands to /usr/local/bin - without putting a space befure /bin

If it is the sole reason to use prefix completion - my example does it as well. It does better job than bash - it checks suffix as well and won't try to complete prefix if the whole completion would fail. Wit zsh you can do:

cd /u/bTAB
It completes to /usr/bin - you realise you made a mistake. Press Undo (^_ or ^Xu by default). You get inital line. Go back, add `l/' like in

cd /u/l/TABb

and it will be completed to /usr/local/bin. But *only* if /usr/local/bin exists. And it will move cursor to the end if you have the single choice or to the first ambiguous place if you have multiple choices. And this is configurable as well :-)

in zsh i can only expand it if i put a space, and then the result looks like:
aura% cd /usr/local/ bin/

complete_in_word doesn't do this (as was mentioned the last time someone
brought this up on the list).  i find the bash way much more intuitive even
if the zsh way is more 'correct'.


You have to use expand-or-complete-prefix instead of expand-or-complete (or complete-word), like

bindkey '^I' expand-or-complete-prefix
setopt completeinword

But then your first problem is back - there is no complete-prefix widget.
It is unlikely that any will be added - new completion can do everything you want and with much better configuration possibilities. (modulo bugs, as looks there are with menu and list styles)

-andrej



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