7:d3613e95e03f
Anton Shestakov <engored@ya.ru>, 2011-11-29
Git info. Git and Mercurial symbols (credit goes to Steve Losh and his extravagant zsh prompt).

next change 9:d83f081c6a41
previous change 5:7b2ad8123a53

.bash_prompt

Other formats: Feeds:
Inserted Replaced Deleted
6:b9fa9529a622 7:d3613e95e03f
local Y="\[\e[1;33m\]" local Y="\[\e[1;33m\]"
local B="\[\e[1;34m\]" local B="\[\e[1;34m\]"
local P="\[\e[1;35m\]" local P="\[\e[1;35m\]"
local C="\[\e[1;36m\]" local C="\[\e[1;36m\]"
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}" local TIME="${G}\t${RESET}"
if [[ ${EUID} == 0 ]] ; then if [[ ${EUID} == 0 ]] ; then
local PROMPT_COLOR="$R" local PROMPT_COLOR="$R"
# getting hg info is disabled for root # getting hg and git info is disabled for root
local HG_INFO=" ${P}-${RESET}" local HG_INFO=" ${P}-${RESET}"
local GIT_INFO=" ${G}-${RESET}"
else else
local PROMPT_COLOR="$G" local PROMPT_COLOR="$G"
# testing if current dir is a part of hg repo # testing if current dir is a part of hg repo
local TEST_DIR="$PWD" local TEST_DIR="$PWD"
while true ; do while true ; do
[[ -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" == '/' ]] && break
TEST_DIR=$(dirname "$TEST_DIR") TEST_DIR=$(dirname "$TEST_DIR")
done done
if [[ "$TRACKED" ]] ; then if [[ "$HG_TRACKED" ]] ; then
local HG_INFO=" $(hg prompt $PROMPT_TEMPLATE)" local HG_INFO=" $(hg prompt $PROMPT_TEMPLATE)"
fi
if [[ "$GIT_TRACKED" ]] ; then
local GIT_STATUS=$(git status 2>/dev/null)
if [[ $(echo ${GIT_STATUS} | grep "# Your branch is behind") ]]; then
local GIT_UPDATE="$R^"
fi
if [[ $(echo ${GIT_STATUS} | grep "# Changes to be committed:") ]]; then
local GIT_STAGED="$R!"
fi
if [[ $(echo ${GIT_STATUS} | grep "# Changes not staged for commit:") ]]; then
local GIT_UNSTAGED="$P?"
fi
local GIT_INFO=" ${G}±${GIT_STAGED}${GIT_UNSTAGED}${GIT_UPDATE}${RESET}"
fi fi
fi fi
if [[ "$VIRTUAL_ENV" ]] ; then if [[ "$VIRTUAL_ENV" ]] ; then
local VENV="${G}+"$(basename "$VIRTUAL_ENV")"${RESET}" local VENV="${G}+"$(basename "$VIRTUAL_ENV")"${RESET}"
local RETCODE="${R}${RETURN_CODE}${RESET} " local RETCODE="${R}${RETURN_CODE}${RESET} "
fi fi
PS1="\ PS1="\
${BOLD}[${TIME} \u@\h \ ${BOLD}[${TIME} \u@\h \
${RETCODE}\W${VENV}${HG_INFO}${BOLD}]\ ${RETCODE}\W${VENV}${HG_INFO}${GIT_INFO}${BOLD}]\
${PROMPT_COLOR}\\\$${RESET} " ${PROMPT_COLOR}\\\$${RESET} "
} }
export PROMPT_COMMAND=prompt_command export PROMPT_COMMAND=prompt_command