Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Advanced scripting Q: notification to tty
- X-seq: zsh-users 8316
- From: <kynn@xxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Advanced scripting Q: notification to tty
- Date: Fri, 24 Dec 2004 13:09:47 -0500 (EST)
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
I want to implement a notification by a function to the terminal
controlling an interactive zsh
For this implementation I'd like to follow the "asynchronous" approach
that zsh uses by default to notify the user when background jobs
finish. By "asynchronous" I mean that the notification does not wait
for the user to hit the return key to show up on the screen; the shell
prints the notification immediately, and simply re-creates the input
line that was interrupted by the notification. The simplest example
of this behavior is barely noticeable:
[25] 13:02 % sleep 1 & ~/local/tmp
[1] 29680
[26] 13:03 % ~/local/tmp
[1] + done sleep 1
[26] 13:03 % ~/local/tmp
Here the notification arrived when the user was not typing anything,
so the shell merely re-produces the left and right prompts (this
*wouldn't* happen after a simple
echo "[1] +done sleep 1"
statement). A more obvious example:
[26] 13:03 % sleep 10 & ~/local/tmp
[1] 29686
[27] 13:04 % echo ' ~/local/tmp
quote> Taking my
quote> sweet time h
[1] + done sleep 10
quote> sweet time here...'
Taking my
sweet time here...
[28] 13:05 % ~/local/tmp
Here 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?
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?
Thanks!
kj
Messages sorted by:
Reverse Date,
Date,
Thread,
Author