agnoster-theme-baz-plugin/plugin/functions/prompt_hg
Ari Archer ef9160c4a6
init
Signed-off-by: Ari Archer <ari.web.xyz@gmail.com>
2022-06-18 23:04:43 +03:00

32 lines
1,018 B
Bash

local rev st branch
if $(hg id >/dev/null 2>&1); then
if $(hg prompt >/dev/null 2>&1); then
if [[ $(hg prompt "{status|unknown}") = "?" ]]; then
# if files are not added
prompt_segment red white
st='±'
elif [[ -n $(hg prompt "{status|modified}") ]]; then
# if any modification
prompt_segment yellow black
st='±'
else
# if working copy is clean
prompt_segment green black $CURRENT_FG
fi
PR="$PR$(hg prompt "☿ {rev}@{branch}") $st"
else
st=""
rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
branch=$(hg id -b 2>/dev/null)
if `hg st | grep -q "^\?"`; then
prompt_segment red white
st='±'
elif `hg st | grep -q "^[MA]"`; then
prompt_segment yellow black
st='±'
else
prompt_segment green black $CURRENT_FG
fi
PR="$PR$rev@$branch $st"
fi
fi