diff options
author | Yohann Bianchi <sbooob@gmail.com> | 2013-01-20 13:10:31 +0100 |
---|---|---|
committer | Yohann Bianchi <sbooob@gmail.com> | 2013-01-20 13:10:31 +0100 |
commit | 28b737416fe1eadd1a0e0bad460941651ac20e49 (patch) | |
tree | e59f90ba911399d9555bd8886d86d538fe389519 | |
parent | 8e9cf45200391db787b3a25ae00f4352d7a11e8e (diff) | |
download | zsh-28b737416fe1eadd1a0e0bad460941651ac20e49.tar.gz zsh-28b737416fe1eadd1a0e0bad460941651ac20e49.tar.bz2 zsh-28b737416fe1eadd1a0e0bad460941651ac20e49.zip |
ADDED: Mercurial prompt info support even if hg prompt extension is unavailable
-rw-r--r-- | themes/agnoster.zsh-theme | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 7ce5a77f8..e2074b713 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -87,18 +87,35 @@ prompt_hg() { local rev status if $(hg id >/dev/null 2>&1); then if $(hg prompt >/dev/null 2>&1); then - rev=$(hg prompt {status}) - if [[ $rev = "?" ]]; then + st=$(hg prompt {status}) + if [[ $st = "?" ]]; then + # if files are not added prompt_segment red white - rev='±' - elif [[ -n $rev ]]; then + st='±' + elif [[ -n $st ]]; then + # if any modification prompt_segment yellow black - rev='±' + 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 fi - echo -n $(hg prompt "⭠ {rev}@{branch}") $rev fi } |