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

Re: Problem with early key strokes at startup



On Feb 28,  2:23am, Sebastian Gniazdowski wrote:
}
} when I startup zsh to just run a tool with Ctrl-O Ctrl-P, I get "^P" or
} "^O^P" printed instead:
} 
} Maybe it's easy to fix?

Unfortunately not.  Typeahead (characters present on stdin before the
shell is ready to read them) is exceptionally difficult to deal with
in a portable way.  There are several lengthy comments about this in
the C code in shell startup and zle.

In this specific case, the problem is likely ctrl-O.  If you look at
output of "stty -a" you'll probably find ^O bound to something called
"flush" which is annoyingly undocumented but means to throw away all
previous input that has not already been read by whatever is connected
to the TTY device.  This is likely being seen and intepreted by the
terminal driver before zsh has a chance to change the state to "raw"
input, and there's absolutely nothing we can do about *that*.

If this is a new shell being spawned by an already-running zsh, you
can try playing around with the value of the STTY environment variable
to disable some of the special tty driver settings ahead of time (see
the zsh manual for how STTY works).  If it's not zsh you'll have to
figure out a different way to frob the driver -- and either way I do
not promise it'll work.



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