Re: select w.o. ENTER

Bart Schaefer <[email protected]>
Newsgroups gmane.comp.shells.zsh.devel
Message-ID <CAH+w=7biqCKn07YOZ2aJ9dvQfQpAG7O3_kZWbcQagt-Q-VT_JQ__20519.7447141231$1778091687$gmane$org@mail.gmail.com>
On Wed, May 6, 2026 at 10:41 AM Ray Andrews <[email protected]> wrote:
>
> On 2026-05-06 09:54, Roman Perepelitsa wrote:
> > How do you want to select the 11th item? Which keys do you want to
> > press for that?
> Ha!  Good point, never thought of that.  But supposing it was a short
> list?  One might want the option.

Hm, the documentation, and the code for the "select" loop, suggests
you should be able to examine $ZLE_STATE for the value "select" but I
can't get that ever to be true.  Aside to workers, code is:
                if (usezle) {
                    int oef = errflag;

                    isfirstln = 1;
                    str = zleentry(ZLE_CMD_READ, &prompt3, NULL,
                                   0, ZLCON_SELECT);
                    if (errflag)
                        str = NULL;
                    /* Keep any user interrupt error status */
                    errflag = oef | (errflag & ERRFLAG_INT);
but ZLCON_SELECT is never populated in $ZLE_STATE, it always comes back with
"globalhistory insert "

However, this appears to work:

qsel() {
  [[ ${(%):-%_} = *select* ]] && zle .accept-line || zle self-insert
}
zle -N qsel
for key in {1..9}; do
  bindkey $key qsel
done
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.