Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Detect typed input without swallowing characters
- X-seq: zsh-users 27505
- From: Marc Cornellà <hello@xxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Detect typed input without swallowing characters
- Date: Thu, 10 Feb 2022 22:21:44 +0100
- Archived-at: <https://zsh.org/users/27505>
- List-id: <zsh-users.zsh.org>
Hi,
in Oh My Zsh we want to detect whether the user has typed characters
before showing the prompt to auto-update, so that if they have, to
skip it entirely and get them to the prompt as fast as possible.
The current solution is to detect whether there's input with `read -t
-k 1`, but this solution has the downside of swallowing one character.
I've been looking at sysread and zselect to poll stdin (fd 0), but I
believe they only tell whether stdin is ready for reading, not whether
it holds any data. These are the commands I'm using by the way:
sysread -t 0 -i 0
zselect -t 0 -r 0
Is there any way to do this or should I give up entirely?
Thanks!
Marc
Messages sorted by:
Reverse Date,
Date,
Thread,
Author