Download:
child 31:697f71f87a33
parent 29:0fcd48b30d83
30:3327ef700923
Anton Shestakov <engored@ya.ru>, Fri, 22 Aug 2014 17:06:56 +0900
Replace hg-prompt-dependent mercurial prompt with hg sum, bash and grep.

1 файлов изменено, 31 вставок(+), 1 удалений(-) [+]
.bash_prompt file | annotate | diff | comparison | revisions
--- a/.bash_prompt Thu Apr 03 01:10:52 2014 +0900
+++ b/.bash_prompt Fri Aug 22 17:06:56 2014 +0900
@@ -35,7 +35,37 @@
done
if [[ "$HG_TRACKED" ]] ; then
- local HG_INFO=" $(hg prompt $PROMPT_TEMPLATE)"
+ 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 REV=${PARENTS[0]}
+ local MERGEREV=${PARENTS[1]}
+
+ BRANCH=${BRANCH/default/}
+ [ -z "$MERGEREV" ] || MERGEREV="+$MERGEREV"
+ case "$COMMIT" in
+ *'(clean)'*)
+ COMMIT=''
+ ;;
+ *added*|*modified*|*deleted*)
+ COMMIT='!'
+ ;;
+ esac
+ case "$UPDATE" in
+ *'(update)'*)
+ UPDATE='^'
+ ;;
+ *'(merge)'*)
+ UPDATE=''
+ ;;
+ *'(current)'*)
+ UPDATE=''
+ ;;
+ esac
+ local HG_INFO=" ${P}${BRANCH}☿${REV}${R}${UPDATE}${G}${MERGEREV}${R}${COMMIT}${RESET}"
fi
if [[ "$GIT_TRACKED" ]] ; then
local GIT_STATUS=$(git status 2>/dev/null)