zsh-users
 help / color / mirror / code / Atom feed
* Detect typed input without swallowing characters
@ 2022-02-10 21:21 Marc Cornellà
  2022-02-11  0:04 ` Philippe Troin
  0 siblings, 1 reply; 5+ messages in thread
From: Marc Cornellà @ 2022-02-10 21:21 UTC (permalink / raw)
  To: zsh-users

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-02-11 19:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-10 21:21 Detect typed input without swallowing characters Marc Cornellà
2022-02-11  0:04 ` Philippe Troin
2022-02-11  9:08   ` Marc Cornellà
2022-02-11 16:15     ` Philippe Troin
2022-02-11 19:08     ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).