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

Re: Detect typed input without swallowing characters



On Fri, 11 Feb 2022 at 01:04, Philippe Troin <phil@xxxxxxxx> wrote:
>
> You can use zselect, but you have to disable canonical mode with stty,
> otherwise characters are not counted unless you press enter (the
> terminal is set to read a whole line at once).
>
> This function should work:
>
>    type_ahead() {
>      emulate -L zsh
>      local termios=$(stty --save)
>      stty -icanon
>      zselect -t 0 -r 0
>      local ret=$?
>      stty $termios
>      return ret
>    }
>

It does work, thanks! I tried my best at using STTY to avoid having to
reset it afterwards, but it didn't have the desired effect.
See https://github.com/ohmyzsh/ohmyzsh/commit/dbd92a62ce1fc25a6819ae6d0a29dc8b8ec9a7dd

Thanks!

Marc




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