Thursday, January 16, 2014

Shows Exit Code of Previous Command in zsh

To display the exit code of the previous command is very useful in zsh.
PS1='%n%m %~ %(?..[%?] )%# '

%(?..[%?] )
It's a conditional expression. The part before the 1st dot is the expression; the part between the two dots is output if it's TRUE (or 0); the part after the second dot is output if it's FALSE (or any number but 0).

See my full customization on .zshrc file.