Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: matching commands by pattern
- X-seq: zsh-users 10859
- From: Frank Terbeck <ft@xxxxxxxxxxxxxxxxxx>
- To: zsh users <zsh-users@xxxxxxxxxx>
- Subject: Re: matching commands by pattern
- Date: Fri, 13 Oct 2006 12:45:53 +0200
- In-reply-to: <200610130930.k9D9UuL7007021@xxxxxxxxxxxxxx>
- Mail-followup-to: zsh users <zsh-users@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Operating-system: Linux 2.6.16.16 i686
- References: <20061013090422.GH4262@xxxxxxxxxxxxxxx> <200610130930.k9D9UuL7007021@xxxxxxxxxxxxxx>
Peter Stephenson <pws@xxxxxxx>:
> Frank Terbeck wrote:
> > I'm trying to be able to use compsys to find all completions, that are
> > possible as the first word of the command-line _and_ match a given
> > pattern. Ideally, these matches should be accessible via a completion
> > menu.
>
> It's easy: just set the option "globcomplete", that's what it's designed
> for. This makes pattern characters active during normal completion, so
> you don't have to do anything else special to get command completion in
> command position.
Thank you, Peter.
This works. But it this way, glob_complete is in effect for every glob
on the command-line when trying to complete.
% ls *.txt<TAB>
drops into a menu, rather than expanding the glob into .txt files.
Would it be possible to enable glob_complete only for the 1st word on
the line other then the following code?
[snip]
function _mycomp () {
setopt localoptions;
local buf
buf=(${(s: :)LBUFFER}) if [[ ${#buf} -eq 1 ]] ; then
setopt globcomplete;
else
setopt noglobcomplete;
fi
zle expand-or-complete
}
zle -N _mycomp
bindkey "^I" _mycomp
[snap]
Regards, Frank
Messages sorted by:
Reverse Date,
Date,
Thread,
Author