zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: "zsh-users" <zsh-users@sunsite.dk>
Subject: Re: reinventing print_exit_value
Date: Mon, 04 Jul 2005 14:32:42 +0000	[thread overview]
Message-ID: <1050704143242.ZM12445@candle.brasslantern.com> (raw)
In-Reply-To: <200507032356.17308.cht@chello.at>

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.)


  parent reply	other threads:[~2005-07-04 14:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-03 21:56 Christian Taylor
2005-07-03 22:32 ` Nikolai Weibull
2005-07-03 23:04   ` Christian Taylor
2005-07-03 23:35     ` Nikolai Weibull
2005-07-04  0:09       ` Christian Taylor
2005-07-04 12:29         ` Nikolai Weibull
2005-07-04 13:24           ` J
2005-07-04 13:25             ` J
2005-07-04 14:29           ` Christian Taylor
2005-07-04 14:32 ` Bart Schaefer [this message]
2005-07-04 22:32   ` Christian Taylor

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=1050704143242.ZM12445@candle.brasslantern.com \
    --to=schaefer@brasslantern.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).