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

Re: select w.o. ENTER



On Wed, May 6, 2026 at 10:41 AM Ray Andrews <rayandrews@xxxxxxxxxxx> 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




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