From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10100 invoked from network); 24 Dec 2004 18:11:46 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 24 Dec 2004 18:11:46 -0000 Received: (qmail 54311 invoked from network); 24 Dec 2004 18:11:40 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 24 Dec 2004 18:11:40 -0000 Received: (qmail 13839 invoked by alias); 24 Dec 2004 18:10:51 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8316 Received: (qmail 13824 invoked from network); 24 Dec 2004 18:10:50 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 24 Dec 2004 18:10:50 -0000 Received: (qmail 52939 invoked from network); 24 Dec 2004 18:09:51 -0000 Received: from mail3.panix.com (166.84.1.74) by a.mx.sunsite.dk with SMTP; 24 Dec 2004 18:09:49 -0000 Received: from panix3.panix.com (panix3.panix.com [166.84.1.3]) by mail3.panix.com (Postfix) with ESMTP id 28DE298221 for ; Fri, 24 Dec 2004 13:09:48 -0500 (EST) Received: (from kynn@localhost) by panix3.panix.com (8.11.6p3/8.8.8/PanixN1.1) id iBOI9lq12047; Fri, 24 Dec 2004 13:09:47 -0500 (EST) Date: Fri, 24 Dec 2004 13:09:47 -0500 (EST) Message-Id: <200412241809.iBOI9lq12047@panix3.panix.com> From: To: zsh-users@sunsite.dk Subject: Advanced scripting Q: notification to tty X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.2 required=6.0 tests=NO_REAL_NAME autolearn=no version=2.63 X-Spam-Hits: 0.2 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