Permalink
Browse files

Put error code in the prompt, if it's not 0.

  • Loading branch information...
1 parent 7809b69 commit a9861356466fa0b7b4b9b961636dcea83dd3ba77 @benhamill committed Jul 11, 2012
Showing with 11 additions and 2 deletions.
  1. +11 −2 bash_prompt
View
@@ -49,9 +49,18 @@ function parse_push_status () {
fi
}
+function error_code () {
+ exit_code=$1
+
+ if [ $exit_code -ne 0 ]; then
+ echo "$exit_code"
+ fi
+}
+
function ps1_function {
- # export PS1="${MAGENTA}●${NORMAL} \W$(parse_git_branch) ${RED}$?${NORMAL}${CYAN}❱${NORMAL} "
- export PS1="${MAGENTA}${NORMAL} \W$(parse_git_branch) ${CYAN}${NORMAL} "
+ error_code=$?
+ export PS1="${MAGENTA}${NORMAL} \W$(parse_git_branch) ${RED}$(error_code $error_code)${NORMAL}${CYAN}${NORMAL} "
+ # export PS1="${MAGENTA}●${NORMAL} \W$(parse_git_branch) ${CYAN}❱${NORMAL} "
}
export PROMPT_COMMAND='ps1_function'

0 comments on commit a986135

Please sign in to comment.