From 5e09986d2d3ab277c97a90dc4424d8f2a9a21089 Mon Sep 17 00:00:00 2001 From: grimborg Date: Thu, 15 May 2014 10:51:39 +0200 Subject: [PATCH] Faster prompt on mercurial --- themes/agnoster.zsh-theme | 42 ++++++++++----------------------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 2b33c48bc..8d0f0e72a 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -105,38 +105,18 @@ prompt_git() { } prompt_hg() { - local rev status - 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 - 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 + local hg_status + hg_status="`hg prompt "{status} {tip} {branch}" 2>/dev/null`" + if (( $? == 0 )); then + if [[ $hg_status == !* ]]; then + prompt_segment yellow black + elif [[ $hg_status == \?* ]]; then + prompt_segment red white + else + prompt_segment green black + fi + echo -n "☿${hg_status}" fi - fi } # Dir: current working directory