zsh-users
 help / color / mirror / code / Atom feed
* globbing
@ 2001-08-10  7:20 Will Yardley
  2001-08-10  9:09 ` globbing Borsenkow Andrej
  2001-08-10  9:43 ` globbing Oliver Kiddle
  0 siblings, 2 replies; 8+ messages in thread
From: Will Yardley @ 2001-08-10  7:20 UTC (permalink / raw)
  To: Zsh Users

well i'm sorry if this is a dumb question, but i really did rtfm... just
haven't been able to figure this one out for a while....

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

in zsh, it'll split out the whole list unless i put the slash after the
asterisk, which can get pretty messy

% cd /home/abuse /home/andrewh /home/ben /home/brad /home/brett /home/brian
/home/charis /home/dadmin ...... and so on and so forth

glob_complete is almost what i want, only ideally i'd like it to not display
the entire array.

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...

i love zsh, but there are a few little things that i still haven't been able
to aproximate.  i'm sure i'll get over it eventually....

w


^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: globbing
  2001-08-10  7:20 globbing Will Yardley
@ 2001-08-10  9:09 ` Borsenkow Andrej
       [not found]   ` <20010810123418.H4701@hq.newdream.net>
  2001-08-10  9:43 ` globbing Oliver Kiddle
  1 sibling, 1 reply; 8+ messages in thread
From: Borsenkow Andrej @ 2001-08-10  9:09 UTC (permalink / raw)
  To: 'Will Yardley', 'Zsh Users'

> well i'm sorry if this is a dumb question, but i really did rtfm...
just
> haven't been able to figure this one out for a while....
> 
> in bash if it hit
> % cd /home/* and hit tab, it just sits there (although i can tab
complete
> other stuff)
> 
> in zsh, it'll split out the whole list unless i put the slash after
the
> asterisk, which can get pretty messy
> 
> % cd /home/abuse /home/andrewh /home/ben /home/brad /home/brett
> /home/brian
> /home/charis /home/dadmin ...... and so on and so forth
> 
> glob_complete is almost what i want, only ideally i'd like it to not
> display
> the entire array.
> 

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?

To switch listing off use setopt nolist and probably nomenu, noautomenu.
I guess you know it. To switch list off only for patterns you need to
use new completion and set styles something like ...

... Oops! I was about to say that you need to use

zstyle ':completion::match:*' list off

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.

> 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...
> 

What's the difference? 

> i love zsh, but there are a few little things that i still haven't
been
> able
> to aproximate.  i'm sure i'll get over it eventually....
>

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

ls /u/l/bTAB

and get it completed to /usr/local/bin. Easier, is not it?

-andrej


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: globbing
  2001-08-10  7:20 globbing Will Yardley
  2001-08-10  9:09 ` globbing Borsenkow Andrej
@ 2001-08-10  9:43 ` Oliver Kiddle
  1 sibling, 0 replies; 8+ messages in thread
From: Oliver Kiddle @ 2001-08-10  9:43 UTC (permalink / raw)
  To: Will Yardley; +Cc: Zsh Users

Will Yardley wrote:
> 

> in zsh, it'll split out the whole list unless i put the slash after the
> asterisk, which can get pretty messy

> glob_complete is almost what i want, only ideally i'd like it to not display
> the entire array.

Have you tried the _match completer? If you don't want the entire array
displayed, what do you want displayed?

> 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?

The _prefix completer is probably what you want then. It ignores the
suffix. It seems to work in the same way as bash to me. So try:
    zstyle ':completion:*::::' completer _match _prefix _complete
making sure you leave the completeinword option set.

Oliver

_____________________________________________________________________
This message has been checked for all known viruses by the 
MessageLabs Virus Scanning Service. For further information visit
http://www.messagelabs.com/stats.asp


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: globbing
       [not found]   ` <20010810123418.H4701@hq.newdream.net>
@ 2001-08-11 11:10     ` Borsenkow Andrej
  2001-08-11 21:23       ` globbing Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Borsenkow Andrej @ 2001-08-11 11:10 UTC (permalink / raw)
  To: Will Yardley; +Cc: zsh-users

[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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: globbing
  2001-08-11 11:10     ` globbing Borsenkow Andrej
@ 2001-08-11 21:23       ` Bart Schaefer
  2001-08-11 21:51         ` globbing Will Yardley
  0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2001-08-11 21:23 UTC (permalink / raw)
  To: Borsenkow Andrej, Will Yardley; +Cc: zsh-users

On Aug 11,  3:10pm, Borsenkow Andrej wrote:
}
} > 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.

You can, however, roll your own (but not in 3.0.x):

  bash-complete () {
    emulate -L zsh
    if [[ $RBUFFER = (|[[:space:]\;\&\|\>]*) ]]
    then
      zle complete-word         # Completing at end of word is not special
    else
      setopt noautomenu         # Cannot menu-complete the prefix, sorry
      RBUFFER[1]=" $RBUFFER[1]" 
      zle complete-word                  
      RBUFFER[1,2]=$RBUFFER[2]           
      if [[ $LBUFFER[-1] = $RBUFFER[1] ]]
      then
	LBUFFER[-1]=''          # Suppress doubled slashes, for example
      fi
    fi
  }
  zle -N bash-complete
  bindkey '\t' bash-complete

This could, I suppose, get added to the collection of bash-alike functions
that PWS has created.  It does appear to work with `setopt bashautolist'.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: globbing
  2001-08-11 21:23       ` globbing Bart Schaefer
@ 2001-08-11 21:51         ` Will Yardley
  2001-08-12  5:42           ` globbing Borsenkow Andrej
  0 siblings, 1 reply; 8+ messages in thread
From: Will Yardley @ 2001-08-11 21:51 UTC (permalink / raw)
  To: zsh-users

Bart Schaefer wrote:
> You can, however, roll your own (but not in 3.0.x):
> 
>   bash-complete () {
>     emulate -L zsh
>     if [[ $RBUFFER = (|[[:space:]\;\&\|\>]*) ]]
>     then
>       zle complete-word         # Completing at end of word is not special
>     else
>       setopt noautomenu         # Cannot menu-complete the prefix, sorry
>       RBUFFER[1]=" $RBUFFER[1]" 
>       zle complete-word                  
>       RBUFFER[1,2]=$RBUFFER[2]           
>       if [[ $LBUFFER[-1] = $RBUFFER[1] ]]
>       then
> 	LBUFFER[-1]=''          # Suppress doubled slashes, for example
>       fi
>     fi
>   }
>   zle -N bash-complete
>   bindkey '\t' bash-complete
> 
> This could, I suppose, get added to the collection of bash-alike functions
> that PWS has created.  It does appear to work with `setopt bashautolist'.

That works _exactly_ how I wanted it to. Perhaps the normal way is better,
but old habits die hard.... thanks for going to the trouble of writing that
function too!

-- 
Sintax error in config file! (line 378)
aborted!


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: globbing
  2001-08-11 21:51         ` globbing Will Yardley
@ 2001-08-12  5:42           ` Borsenkow Andrej
  0 siblings, 0 replies; 8+ messages in thread
From: Borsenkow Andrej @ 2001-08-12  5:42 UTC (permalink / raw)
  To: Will Yardley; +Cc: zsh-users

Will Yardley wrote:
> Bart Schaefer wrote:
> 
>>You can, however, roll your own (but not in 3.0.x):
> 
> That works _exactly_ how I wanted it to. Perhaps the normal way is better,
> but old habits die hard.... thanks for going to the trouble of writing that
> function too!
> 

Now you see why it is better to keep discussion on the list :-)

-andrej


^ permalink raw reply	[flat|nested] 8+ messages in thread

* globbing
@ 2005-07-21  2:48 Tyler Spivey
  0 siblings, 0 replies; 8+ messages in thread
From: Tyler Spivey @ 2005-07-21  2:48 UTC (permalink / raw)
  To: zsh-users

How can I get this to work? I want to read a filespec from the user,
then expand it into an array from a variable. e.g. (nonworking code):
f=\*
a=($f)
This should work, since a=(*) will work.
How can I force filename generation?
Thanks,
Tyler


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-07-21  2:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-10  7:20 globbing Will Yardley
2001-08-10  9:09 ` globbing Borsenkow Andrej
     [not found]   ` <20010810123418.H4701@hq.newdream.net>
2001-08-11 11:10     ` globbing Borsenkow Andrej
2001-08-11 21:23       ` globbing Bart Schaefer
2001-08-11 21:51         ` globbing Will Yardley
2001-08-12  5:42           ` globbing Borsenkow Andrej
2001-08-10  9:43 ` globbing Oliver Kiddle
2005-07-21  2:48 globbing Tyler Spivey

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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).