Add return codes to your shell prompt

How many times do you type 'echo $?' to check if the command you have just run really didn't silently exit with an error? When I do sys admin stuff I frequently do this. So now I just added the return code to my shell prompt. So if something goes wrong I see it right away. I have a FreeBSD box so this may vary from setup to setup.
export PS1='[\u@\h \w] $(echo $?) \$ '
the trick is the
$(echo $?)
I know this forks a new echo process every time you get a shell prompt. But the idea is that you enable this when you are doing important selected stuff. Possibly on a live system where you are not allowed to make any errors.

No comments: