Re: select w.o. ENTER

"Mark J. Reed" <[email protected]>
Newsgroups gmane.comp.shells.zsh.devel,gmane.comp.shells.zsh.user
Message-ID <CAA=-s3yhf+1TZXDQ-dLStth4HLfx3PYMh8N6Tr8m6B64_9zk8w@mail.gmail.com>
That's just not how select(1) works. If you want a menu that lets the user
respond with a keypress, you need to roll your own.

chosen=0
while (( chosen < 1 || chosen >$#path )); do
    for (( i=1; i<$#path; ++i)); do
        printf '%d) %s\n' "$i" "${path[i]}"
    done
    printf '%s' "$PS3"
    read -k chosen
done
pith=$path[$chosen]


If I'm doing single-key input though I'm probably not also using text menus
anyway. I find it much more useful to have a select body that does a
pattern match so you can type the value instead of just the index.


On Wed, May 6, 2026 at 1:42 PM 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.
>
>
>

-- 
Mark J. Reed <[email protected]>
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.