Anton Shestakov <engored@ya.ru>, Mon, 25 Aug 2014 14:41:33 +0900
Finally .hgrc.
.bash_prompt
Permissions: -rw-r--r--
function prompt_command
{ 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 and git info is disabled for root local HG_INFO=" ${P}-${RESET}" local GIT_INFO=" ${G}-${RESET}" # testing if current dir is a part of hg repo [[ -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 [[ "$HG_TRACKED" ]] ; then local SUM=$(LC_ALL=C hg sum
) local PARENTS=($(echo "$SUM" | grep -Po
'(?<=parent: ).*(?=:)')) local BRANCH=$(echo "$SUM" | grep -Po
'(?<=branch: ).*$') local COMMIT=$(echo "$SUM" | grep -Po
'(?<=commit: ).*$') local UPDATE=$(echo "$SUM" | grep -Po
'(?<=update: ).*$') local MERGEREV=${PARENTS[1]} BRANCH=${BRANCH/default/} [ -z
"$MERGEREV" ] || MERGEREV="+$MERGEREV" *added*
|*modified*
|*deleted*
) local HG_INFO=" ${P}${BRANCH}☿${REV}${R}${UPDATE}${G}${MERGEREV}${R}${COMMIT}${RESET}" if [[ "$GIT_TRACKED" ]] ; then local GIT_STATUS=$(git status
2>/dev/null
) local GIT_BRANCH=$(grep
'On branch' <<< "$GIT_STATUS" | cut -d
' ' -f3-
) if [[ $(grep
"Your branch is behind" <<< "$GIT_STATUS") ]]; then if [[ $(grep
"Changes to be committed" <<< "$GIT_STATUS") ]]; then if [[ $(grep
"Changes not staged" <<< "$GIT_STATUS") ]]; then local GIT_INFO=" ${G}${GIT_BRANCH}±${GIT_STAGED}${GIT_UNSTAGED}${GIT_UPDATE}${RESET}" if [[ "$VIRTUAL_ENV" ]] ; then local VENV="${G}+"$(basename
"$VIRTUAL_ENV")"${RESET}" if [[ "$RETURN_CODE" !
= 0 ]] ; then local RETCODE="${R}${RETURN_CODE}${RESET} " ${RETCODE}\W${VENV}${HG_INFO}${GIT_INFO}${BOLD}]\ ${PROMPT_COLOR}\\\$${RESET} " export VIRTUAL_ENV_DISABLE_PROMPT="1" export PROMPT_COMMAND=prompt_command