I wish to show exit code on Bash shell prompt, so that I can easily know whether the previous command run successfully, however, it always show 0. Anything wrong with this? Then is it possible to accomplish the desired result?
PS1="\t <\w> ERR:$(echo $?) \$ "

— Bash 4.1.10 on openSUSE 11.4
You forgot to escape the
$in order to inhibit expansion when the assignment is executed.