This commit is contained in:
Òscar Vilaplana 2014-12-15 00:31:22 +00:00
commit c448b36dcd
2 changed files with 14 additions and 31 deletions

View file

@ -11,6 +11,9 @@ if (( $+commands[$virtualenvwrapper] )); then
WORKON_CWD=1 WORKON_CWD=1
# Check if this is a Git repo # Check if this is a Git repo
PROJECT_ROOT=`git rev-parse --show-toplevel 2> /dev/null` PROJECT_ROOT=`git rev-parse --show-toplevel 2> /dev/null`
if (( $? != 0 )); then
PROJECT_ROOT=`hg prompt '{root}' 2>/dev/null`
fi
if (( $? != 0 )); then if (( $? != 0 )); then
PROJECT_ROOT="." PROJECT_ROOT="."
fi fi

View file

@ -103,38 +103,18 @@ prompt_git() {
} }
prompt_hg() { prompt_hg() {
local rev status local hg_status
if $(hg id >/dev/null 2>&1); then hg_status="`hg prompt "{status} {tip} {branch}" 2>/dev/null`"
if $(hg prompt >/dev/null 2>&1); then if (( $? == 0 )); then
if [[ $(hg prompt "{status|unknown}") = "?" ]]; then if [[ $hg_status == !* ]]; then
# if files are not added prompt_segment yellow black
prompt_segment red white elif [[ $hg_status == \?* ]]; then
st='±' prompt_segment red white
elif [[ -n $(hg prompt "{status|modified}") ]]; then else
# if any modification prompt_segment green black
prompt_segment yellow black fi
st='±' echo -n "☿${hg_status}"
else
# if working copy is clean
prompt_segment green black
fi
echo -n $(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 -Eq "^\?"`; then
prompt_segment red black
st='±'
elif `hg st | grep -Eq "^(M|A)"`; then
prompt_segment yellow black
st='±'
else
prompt_segment green black
fi
echo -n "☿ $rev@$branch" $st
fi fi
fi
} }
# Dir: current working directory # Dir: current working directory