d1ce70f68540bdf6a7f27ab9879e8222d0e7a604

Author
grindhold <grindhold@users.noreply.github.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

added support for bazaar in agnoster theme (#5016)

the agnoster theme is now able to render basic information
if the user is currently residing inside a bazaar folder.
if so, it will render a green promt segment with "bzr" and
the current revision number in it. if there are untracked
files, the bar will be rendered in yellow. if there are
changes to already tracked files, a + character will be
printed.

Diff

 1diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme
 2index da1f9b6e6dfcaaebbdef2d47d63484e263b20e1f..e1a294ee8e3868094edc155120c1eafc545bbf5d 100644
 3--- a/themes/agnoster.zsh-theme
 4+++ b/themes/agnoster.zsh-theme
 5@@ -127,6 +127,27 @@ prompt_git() {
 6   fi
 7 }
 8 
 9+prompt_bzr() {
10+    if (bzr status >/dev/null 2>&1); then
11+        status_mod=`bzr status | head -n1 | grep "modified" | wc -m`
12+        status_all=`bzr status | head -n1 | wc -m`
13+        revision=`bzr log | head -n2 | tail -n1 | sed 's/^revno: //'`
14+        if [[ $status_mod -gt 0 ]] ; then
15+            prompt_segment yellow black
16+            echo -n "bzr@"$revision "✚ "
17+        else
18+            if [[ $status_all -gt 0 ]] ; then
19+                prompt_segment yellow black
20+                echo -n "bzr@"$revision
21+
22+            else
23+                prompt_segment green black
24+                echo -n "bzr@"$revision
25+            fi
26+        fi
27+    fi
28+}
29+
30 prompt_hg() {
31   (( $+commands[hg] )) || return
32   local rev status
33@@ -198,6 +219,7 @@ build_prompt() {
34   prompt_context
35   prompt_dir
36   prompt_git
37+  prompt_bzr
38   prompt_hg
39   prompt_end
40 }