I want to print exit code of previous command in shell if it failed. So I changed PS1
variable in /etc/bash.bashrc
like this:
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w [$?] \$ '
#_______________________________________________^^^^_____
but it always print the exit code of the previous command. Is there any way to add condition in the template so if $?
is equal to 0
, it does not print $?