Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Conditional newline in prompt



Sorry, forgot to change the recipient. Might be worth using Reply-To.

On 12/01/2010 09:58 PM, Mikael Magnusson wrote:
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
~>


Thanks Mikael, there's an obvious solution I've overlooked while it was staring me in the face. ;-)

Christoph



Messages sorted by: Reverse Date, Date, Thread, Author