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

Conditional newline in prompt



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?

Kind regards
Christoph



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