diff options
author | Robby Russell <robby@planetargon.com> | 2013-03-26 22:05:55 -0700 |
---|---|---|
committer | Robby Russell <robby@planetargon.com> | 2013-03-26 22:05:55 -0700 |
commit | 4e101bed8661c342eade6d4ad094bdf3337b3b2e (patch) | |
tree | 33e9ad28573286536a43f5c887437559e9e6a855 | |
parent | 22390353682f742d8ea5e7ef0ec451fa836f2654 (diff) | |
parent | 5128669a76a744883ad51df7682577e6654418e1 (diff) | |
download | zsh-4e101bed8661c342eade6d4ad094bdf3337b3b2e.tar.gz zsh-4e101bed8661c342eade6d4ad094bdf3337b3b2e.tar.bz2 zsh-4e101bed8661c342eade6d4ad094bdf3337b3b2e.zip |
Merge pull request #1558 from sbooob/master
Mercurial repository info in agnoster theme
-rw-r--r-- | themes/agnoster.zsh-theme | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index c3107c06c..75e095776 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -83,6 +83,41 @@ prompt_git() { fi } +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 + fi + fi +} + # Dir: current working directory prompt_dir() { prompt_segment blue black '%~' @@ -109,6 +144,7 @@ build_prompt() { prompt_context prompt_dir prompt_git + prompt_hg prompt_end } |