--- a/.bash_prompt Mon Nov 21 15:31:47 2011 +0800
+++ b/.bash_prompt Tue Nov 29 17:33:33 2011 +0800
- local PROMPT_TEMPLATE="${P}{branch|quiet}@{rev}{$R{update}}{$G+{rev|merge}}$R{status|modified}${RESET}"
+ local PROMPT_TEMPLATE="${P}{branch|quiet}☿{rev}{$R{update}}{$G+{rev|merge}}$R{status|modified}${RESET}"
local TIME="${G}\t${RESET}"
if [[ ${EUID} == 0 ]] ; then
- # getting hg info is disabled for root
+ # getting hg and git info is disabled for root
local HG_INFO=" ${P}-${RESET}"
+ local GIT_INFO=" ${G}-${RESET}"
- [[ -d "$TEST_DIR/.hg" ]] && local TRACKED=1 && break
+ [[ -d "$TEST_DIR/.hg" ]] && local HG_TRACKED=1 && break
+ [[ -d "$TEST_DIR/.git" ]] && local GIT_TRACKED=1 && break
[[ "$TEST_DIR" == '/' ]] && break
TEST_DIR=$(dirname "$TEST_DIR")
- if [[ "$TRACKED" ]] ; then
+ if [[ "$HG_TRACKED" ]] ; then
local HG_INFO=" $(hg prompt $PROMPT_TEMPLATE)"
+ if [[ "$GIT_TRACKED" ]] ; then
+ local GIT_STATUS=$(git status 2>/dev/null)
+ if [[ $(echo ${GIT_STATUS} | grep "# Your branch is behind") ]]; then
+ if [[ $(echo ${GIT_STATUS} | grep "# Changes to be committed:") ]]; then
+ if [[ $(echo ${GIT_STATUS} | grep "# Changes not staged for commit:") ]]; then
+ local GIT_UNSTAGED="$P?"
+ local GIT_INFO=" ${G}±${GIT_STAGED}${GIT_UNSTAGED}${GIT_UPDATE}${RESET}"
if [[ "$VIRTUAL_ENV" ]] ; then
-${RETCODE}\W${VENV}${HG_INFO}${BOLD}]\
+${RETCODE}\W${VENV}${HG_INFO}${GIT_INFO}${BOLD}]\
${PROMPT_COLOR}\\\$${RESET} "