zsh-users
 help / color / mirror / code / Atom feed
From: <kynn@panix.com>
To: zsh-users@sunsite.dk
Subject: Advanced scripting Q: notification to tty
Date: Fri, 24 Dec 2004 13:09:47 -0500 (EST)	[thread overview]
Message-ID: <200412241809.iBOI9lq12047@panix3.panix.com> (raw)



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


             reply	other threads:[~2004-12-24 18:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-24 18:09 kynn [this message]
2005-01-03 16:37 ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200412241809.iBOI9lq12047@panix3.panix.com \
    --to=kynn@panix.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).