Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: _complete: insert unambiguous when globbing
- X-seq: zsh-users 27454
- From: Tomasz Pala <gotar@xxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: _complete: insert unambiguous when globbing
- Date: Thu, 6 Jan 2022 02:52:21 +0100
- Archived-at: <https://zsh.org/users/27454>
- In-reply-to: <CAH+w=7Z_iezjS6QngRPAKyy63-J7q535DWV=-5fEw9xiVcLhNw@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <20220103123903.GA20434@polanet.pl> <CAH+w=7YobgajzubM-nhbr39cHUn=WcaKMG4oXRkZiorWgdvbjg@mail.gmail.com> <20220105194643.GA13958@polanet.pl> <CAH+w=7Z_iezjS6QngRPAKyy63-J7q535DWV=-5fEw9xiVcLhNw@mail.gmail.com>
On Wed, Jan 05, 2022 at 12:11:54 -0800, Bart Schaefer wrote:
> Aha! That's given me the answer.
>
> You want something along the lines of:
>
> unsetopt globcomplete
> zstyle ':completion:*' completer _complete _match _expand
> zstyle ':completion::match:*' insert-unambiguous true
Smart one! This is nice, but this time I got other issues:
$ rpm --*er[tab]
without glob_complete, this method of finding options for SOME commands
stops working. What's the difference between ps --* and ls --* that the
latter still works?
And back to my example:
$ touch 2021.12.29-14:41:02.xz 2021.12.29-19:41:02.xz 2021.12.30-03:41:03.xz 2021.12.30-14:41:04.xz 2021.12.30-19:41:02.xz 2021.12.31-03:41:02.xz 2021.12.31-14:41:04.xz 2021.12.31-19:41:03.xz
$ ls *04[tab]
- this one is much nicer than my version, goes directly to:
$ ls 2021.12.3-14:41:04.xz (note the suffix)
with cursor __^__ placed here, on dash. However, unless I move cursor
left+right manually, pressing tab second time moves cursor to the end
with uncompletable line...
And following one fails miserably...
$ ls *z[tab]
$ ls 2021.12.-
See the dash at the end? From now on, no completion... This problem is
solved by alternating order to _expand _complete _match.
Apparently _complete _match parts doesn't work well here in that order,
however _match _complete (only!) works just like my solution without
compstate[old_list]=keep, therefore one of the following seems to work fine:
zstyle ':completion:*' completer _match _oldlist _complete
zstyle ':completion:*' completer _expand _match _oldlist _complete _prefix
But no suffix added, just like in my version.
Moreover, in this order there's no need to unsetopt glob_complete.
Am I missing something?
There is still one issue with coloring completions, that works fine with
my approach, but seems to be stuck on _oldlist:
highlights='${PREFIX:+=(*/|)(#bi)($PREFIX|$PREFIX:t)(?)(*(${LASTSEARCH})*)#*==1;32=1;31==1;32}':${(s.:.)LS_COLORS}
zstyle -e ':completion:*:*' list-colors 'reply=( "'$highlights'" "ma=44;1;33")'
With _oldlist in action the colors are not updated after prepending the
unambiguous part.
> The use of insert-unambiguous will set compstate[pattern_insert]
> correctly for you. You might also try the value "pattern" for that
> zstyle.
--
Tomasz Pala <gotar@xxxxxxxxxxxxx>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author