Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Conditional newline in prompt
- X-seq: zsh-users 15585
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Christoph Wurm <christoph@xxxxxxxx>
- Subject: Re: Conditional newline in prompt
- Date: Wed, 1 Dec 2010 21:58:36 +0100
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=myWP+obnKk1B9Z+3aYvmrZsKq+NgmZhMqVvh27QmS1o=; b=jnExh2N8jA1kMO3Qd9sMCkYlx2zFEZ+KmMTgiU6JPcwpYKeykT/PBqsHHXzcntLbTe Z6vWiKRuXNbeO3RXQARmlE2nJtEsgNNwOH67lzvQUOXuxqui+uKvEtnM9M0g0DuR/F9H em/RcTAgeiTVTrZy5XiioSM6B5FkgMgxLOf8Q=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=dyR3Xhz9opKNV/O0FDhfMEmqTSWdsr48Fnc1YFeVZ3OLoWvseBwIGYi9psQ7Yih6WT hTHiwIaoFV3285GAd2B1Ed8BdvhCnvfd/gZil5wV10JSwfsw2VisyW1O2i7Mk67NZdG3 sErxZyN9tiGLfUawIxhg3DhjDWwym6jt9JGQQ=
- In-reply-to: <4CF6B323.9000607@xxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <4CF6B323.9000607@xxxxxxxx>
On 1 December 2010 21:42, Christoph Wurm <christoph@xxxxxxxx> wrote:
> Hello,
>
> I would like to display the exit code of a command if it is not 0 on a line
> of its own, followed by the prompt on the next line.
>
> Is this possible?
>
> I was able to come up with the following:
>
> PROMPT="%0(?..%?)
> %{$fg[green]%}%n@%m%{$reset_color%}:%~ %{$fg[red]%}%#%{$reset_color%} "
>
> However, this prints a newline after every command. Is there some equivalent
> of '\n' that can be used inside the conditional substring? Or some other way
> to do this?
Yes, a newline works fine.
% PS1='%0(?..%?
)%~> '
~> false
1
~> true
~>
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author