Last Updated: February 25, 2016
·
6.038K
· fstoerkle

ZSH prompt: exit status of last command

Perhaps you are as curious as me and want to know the exit status of the last command you ran in your ZSH-powered Terminal?

Then use the following code and put it into your ~/.zshrc file
autoload -U colors && colors
local returncode="%(?..%{$fg[red]%} %? ↵%{$resetcolor%})"
export RPS1='$(gitinfo)${returncode}'

This will show you the exit code of the last command, if it did not exit successfully (by UNIX convention: if the exit code is bigger than 0).

Special features included: it's colored and shown on the right side!