From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19738 invoked from network); 4 Jul 2005 14:33:04 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 4 Jul 2005 14:33:04 -0000 Received: (qmail 28482 invoked from network); 4 Jul 2005 14:32:58 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 4 Jul 2005 14:32:58 -0000 Received: (qmail 24420 invoked by alias); 4 Jul 2005 14:32:50 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9023 Received: (qmail 24411 invoked from network); 4 Jul 2005 14:32:50 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 4 Jul 2005 14:32:50 -0000 Received: (qmail 27345 invoked from network); 4 Jul 2005 14:32:50 -0000 Received: from vms044pub.verizon.net (206.46.252.44) by a.mx.sunsite.dk with SMTP; 4 Jul 2005 14:32:46 -0000 Received: from candle.brasslantern.com ([71.116.88.149]) by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix 0.04 (built Dec 24 2004)) with ESMTPA id <0IJ3006ADXQK1K6F@vms044.mailsrvcs.net> for zsh-users@sunsite.dk; Mon, 04 Jul 2005 09:32:45 -0500 (CDT) Received: from candle.brasslantern.com (IDENT:schaefer@localhost [127.0.0.1]) by candle.brasslantern.com (8.12.11/8.12.11) with ESMTP id j64EWhEh012447 for ; Mon, 04 Jul 2005 07:32:43 -0700 Received: (from schaefer@localhost) by candle.brasslantern.com (8.12.11/8.12.11/Submit) id j64EWhXu012446 for zsh-users@sunsite.dk; Mon, 04 Jul 2005 07:32:43 -0700 Date: Mon, 04 Jul 2005 14:32:42 +0000 From: Bart Schaefer Subject: Re: reinventing print_exit_value In-reply-to: <200507032356.17308.cht@chello.at> To: "zsh-users" Message-id: <1050704143242.ZM12445@candle.brasslantern.com> MIME-version: 1.0 X-Mailer: Z-Mail (5.0.0 30July97) Content-type: text/plain; charset=us-ascii References: <200507032356.17308.cht@chello.at> Comments: In reply to Christian Taylor "reinventing print_exit_value" (Jul 3, 11:56pm) X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 On Jul 3, 11:56pm, Christian Taylor wrote: } } However: is there a simpler way to achieve this? My solution seems a bit } inelegant to me. How about this way of putting it into the prompt? PS1="%{%(0?..$(echotc DO 1)$(echotc sc) $(echotc rc)$(echotc UP 1))%}%# %{%(0?..$(echotc sc) (%?%)$(echotc rc))%}" Translation: Counting no size for this output - - if $? is 0, output nothing - else, try to move down one line, then save the cursor position, output a newline, restore the cursor position and try to move up one line. Output a percent or pound character followed by a space. Counting no size for this output - - if $? is 0, output nothing - else, save the cursor position, emit a newline and the value of $? in parens and restore the cursor. What this does is cause an extra line to be added BELOW the regular prompt, rather than above it, which contains the nonzero exit status. Each time you hit enter at the prompt, the new prompt covers up the previous result and displays it again, so it's always visible but never occupies more than one vertical line of your screen. You may need to adjust that first part for your terminal; it's intended to handle vt100/xterm save/restore cursor behavior at any line of the screen, including the last line where emitting a newline scrolls the text but does not change the saved position. It doesn't always work properly when NO_PROMPT_CR is set because ZLE may reposition the cursor again after the prompt has been printed. (This may be an issue only in 4.0.x rather than 4.2.x.)