I have this in my .bashrc:
LIGHTGREEN=\"\\[\\033[1;32m\\]\"
LIGHTRED=\"\\[\\033[1;31m\\]\"
WHITE=\"\\[\\033[0;37m\\]\"
RESET=\"\\[\\033[0;00m\\]\"
function
Here's the coloured exit code portion of my PS1 code:
color_enabled() {
local -i colors=$(tput colors 2>/dev/null)
[[ $? -eq 0 ]] && [[ $colors -gt 2 ]]
}
BOLD_FORMAT="${BOLD_FORMAT-$(color_enabled && tput bold)}"
ERROR_FORMAT="${ERROR_FORMAT-$(color_enabled && tput setaf 1)}"
RESET_FORMAT="${RESET_FORMAT-$(color_enabled && tput sgr0)}"
# Exit code
PS1='$(exit_code=$?; [[ $exit_code -eq 0 ]] || printf %s $BOLD_FORMAT $ERROR_FORMAT $exit_code $RESET_FORMAT " ")'
Screenshot (with one Subversion repository path anonymized):