Created
October 20, 2011 17:40
-
-
Save rweald/1301763 to your computer and use it in GitHub Desktop.
Way to get colored bash prompt based on git status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#configuration for my bash prompt | |
prompt_function() { | |
local BLACK='\[\033[0;30m\]' | |
local LIGHT_BLACK='\[\033[1;30m\]' | |
local RED='\[\033[0;31m\]' | |
local LIGHT_RED='\[\033[1;31m\]' | |
local GREEN='\[\033[0;32m\]' | |
local LIGHT_GREEN='\[\033[1;32m\]' | |
local YELLOW='\[\033[0;33m\]' | |
local LIGHT_YELLOW='\[\033[1;33m\]' | |
local BLUE='\[\033[0;34m\]' | |
local LIGHT_BLUE='\[\033[1;34m\]' | |
local PURPLE='\[\033[0;35m\]' | |
local LIGHT_PURPLE='\[\033[1;35m\]' | |
local CYAN='\[\033[0;36m\]' | |
local LIGHT_CYAN='\[\033[1;36m\]' | |
local DARK_WHITE='\[\033[0;37m\]' | |
local WHITE='\[\033[1;37m\]' | |
local RESET='\[\033[0m\]' | |
# previous_return_value=$?; | |
# case $previous_return_value in | |
# 0) | |
# prompt_color="${RESET}" | |
# ;; | |
# 1) | |
# prompt_color="${LIGHT_RED}" | |
# ;; | |
# *) | |
# prompt_color="${LIGHT_YELLOW}" | |
# ;; | |
# esac | |
# use "${prompt_color}\$${RESET}" instead of "\$" below | |
if test $(git status 2> /dev/null | grep -c :) -eq 0; then | |
git_color="${GREEN}" | |
else | |
git_color="${RED}" | |
fi | |
PS1="${RESET}${CYAN}\u${RESET}: \w${git_color}$(__git_ps1)${RESET}\$ " | |
} | |
PROMPT_COMMAND=prompt_function | |
#configuration for autojump | |
if [ -f `brew --prefix`/etc/autojump ]; then | |
. `brew --prefix`/etc/autojump | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment