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

Re: Advanced scripting Q: notification to tty

On Fri, 24 Dec 2004 kynn@xxxxxxxxx wrote:

> I want to implement a notification by a function to the terminal
> controlling an interactive zsh
> [...] the shell's notification arrives while the user is in the middle
> of typing a multi-line command, so the shell re-creates the
> interrupted line for the user.  *Very nicely done*.
> Does zsh provide any facilities for programmers to achieve this effect
> in shell scripts?

Yes, look at the "zle" command's -F option which allows you to install an
asynchronous I/O handler function in the line editor.  See also "zle -I".

> Absent this, what is the best way to implement "synchronous" 
> notification (i.e. one that happens only after the user hits the Enter 
> key) in zsh scripts?

Have the notifier write to a named pipe (or use the coproc descriptor) and 
examine that for available input in the user-definable precmd function.

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