Download:
child 43:0b7988041786
parent 41:14d2a23ab38f
42:34ee83bd5ad2
Anton Shestakov <engored@ya.ru>, Fri, 29 Aug 2014 02:51:26 +0900
local again. Lotsa colors. hg prompt is back, controlled by USE_HG_PROMPT.

1 файлов изменено, 37 вставок(+), 20 удалений(-) [+]
.bash_prompt file | annotate | diff | comparison | revisions
--- a/.bash_prompt Thu Aug 28 21:01:58 2014 +0900
+++ b/.bash_prompt Fri Aug 29 02:51:26 2014 +0900
@@ -1,19 +1,36 @@
#!/bin/bash
-RETURN_CODE="$?"
-RESET="\[\e[0m\]"
-BOLD="\[\e[1m\]"
+function prompt_command {
+ local RETURN_CODE="$?"
+
+ # dark, light, bold
+ local Rd="\[\e[0;31m\]"; local R="\[\e[0;91m\]"; local Rb="\[\e[1;31m\]"
+ local Gd="\[\e[0;32m\]"; local G="\[\e[0;92m\]"; local Gb="\[\e[1;32m\]"
+ local Yd="\[\e[0;33m\]"; local Y="\[\e[0;93m\]"; local Yb="\[\e[1;33m\]"
+ local Bd="\[\e[0;34m\]"; local B="\[\e[0;94m\]"; local Bb="\[\e[1;34m\]"
+ local Pd="\[\e[0;35m\]"; local P="\[\e[0;95m\]"; local Pb="\[\e[1;35m\]"
+ local Cd="\[\e[0;36m\]"; local C="\[\e[0;96m\]"; local Cb="\[\e[1;36m\]"
-R="\[\e[1;31m\]"
-G="\[\e[1;32m\]"
-Y="\[\e[1;33m\]"
-B="\[\e[1;34m\]"
-P="\[\e[1;35m\]"
-C="\[\e[1;36m\]"
+ if [[ $TERM == 'linux' ]] ; then
+ R=$Rb
+ G=$Gb
+ Y=$Yb
+ B=$Bb
+ P=$Pb
+ C=$Cb
+ fi
-TIME="${G}\t${RESET}"
+ local BOLD="\[\e[1m\]"
+ local RESET="\[\e[0m\]"
+
+ local TIME="${G}\t${RESET}"
-function prompt_command {
+ local USE_HG_PROMPT=
+
+ if [[ $RETURN_CODE != 0 ]] ; then
+ local RETCODE="${R}${RETURN_CODE}${RESET} "
+ fi
+
if [[ $EUID == 0 ]] ; then
local PROMPT_COLOR="$R"
@@ -33,7 +50,11 @@
TEST_DIR=$(dirname "$TEST_DIR")
done
- if [[ $HG_TRACKED ]] ; then
+ if [[ $HG_TRACKED && $USE_HG_PROMPT ]] ; then
+ local PROMPT_TEMPLATE="${P}{branch|quiet}{${Rd}{closed}}${P}☿{rev}{${B}+{tags|quiet|+}}{${Gd}*{bookmark}}{${R}{update}}{${G}+{rev|merge}}${R}{status|modified}${RESET}"
+ local HG_INFO=" $(hg prompt $PROMPT_TEMPLATE)"
+ fi
+ if [[ $HG_TRACKED && ! $USE_HG_PROMPT ]] ; then
local SUM=$(LC_ALL=C hg sum 2>/dev/null)
local PARENTS=($(grep -Po '(?<=parent: ).*(?=:)' <<< "$SUM"))
local BRANCH=$(grep -Po '(?<=branch: ).*$' <<< "$SUM")
@@ -71,18 +92,18 @@
local GIT_BRANCH=$(grep -Po '(?<=On branch ).*$' <<< "$GIT_STATUS")
local GIT_REV=$(LC_ALL=C git rev-parse --short HEAD 2>/dev/null)
- if [[ $GIT_STATUS == *'Your branch is behind'* ]]; then
+ if [[ $GIT_STATUS == *'Your branch is behind'* ]] ; then
local GIT_BEHIND="$R^"
[[ $GIT_STATUS =~ behind[^$'\n']+([0-9]+)' 'commit ]] && GIT_BEHIND+=${BASH_REMATCH[1]}
fi
- if [[ $GIT_STATUS == *'Your branch is ahead'* ]]; then
+ if [[ $GIT_STATUS == *'Your branch is ahead'* ]] ; then
local GIT_AHEAD="$Y^"
[[ $GIT_STATUS =~ ahead[^$'\n']+([0-9]+)' 'commit ]] && GIT_AHEAD+=${BASH_REMATCH[1]}
fi
- if [[ $GIT_STATUS == *'Changes to be committed'* ]]; then
+ if [[ $GIT_STATUS == *'Changes to be committed'* ]] ; then
local GIT_STAGED="$R!"
fi
- if [[ $GIT_STATUS == *'Changes not staged'* ]]; then
+ if [[ $GIT_STATUS == *'Changes not staged'* ]] ; then
local GIT_UNSTAGED="$P?"
fi
@@ -94,10 +115,6 @@
local VENV="${G}+"$(basename "$VIRTUAL_ENV")"${RESET}"
fi
- if [[ $RETURN_CODE != 0 ]] ; then
- local RETCODE="${R}${RETURN_CODE}${RESET} "
- fi
-
PS1="\
${BOLD}[${TIME} \u@\h \
${RETCODE}\W${VENV}${HG_INFO}${GIT_INFO}${BOLD}]\