You may already know this technique, but just in case - Instead of `echo
$?` I like to set my prompt to show the return code of programs, but only
in case of errors. Here's the bash script:

# meant to be sourced from your bash environment
# this will display a colored error code if the previous function
# returned an error, or just the regular prompt otherwise.
#
# JPM <[EMAIL PROTECTED]>

showIfError ()
{
  AUX=$?;
  if [ $AUX -gt 0 ]; then PREFIX="\[\033[1;33m\][${AUX}] "; else
PREFIX=""; fi
  PS1="${PREFIX}\[\033[1;32m\]\w\[\033[0;0m\]\$ ";
}

PROMPT_COMMAND=showIfError


You can test that with commands like `test 1 == 2` which return an error
code.

The code above also has colors, but you can remove them if you prefer a
vanilla prompt.

Cheers,
JP
_______________________________________________
Siglinux mailing list
[EMAIL PROTECTED]
http://machito.utacm.org/mailman/listinfo/siglinux

Reply via email to