diff options
author | Marc Cornellà <marc.cornella@live.com> | 2020-02-19 00:16:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-19 00:16:54 +0100 |
commit | c1b798aff39942b2f23a0a5f2ef206ebc8ce4970 (patch) | |
tree | 7cbc72b8cf9de09ca0894e8b9bcff27d95959881 /themes | |
parent | eeb49bf5b0b8b700713e5b91464003cc09d1b44d (diff) | |
download | zsh-c1b798aff39942b2f23a0a5f2ef206ebc8ce4970.tar.gz zsh-c1b798aff39942b2f23a0a5f2ef206ebc8ce4970.tar.bz2 zsh-c1b798aff39942b2f23a0a5f2ef206ebc8ce4970.zip |
agnoster: fix bzr prompt with breezy installed (#8646)
* Change indentation to 2 spaces in prompt_bzr function
* Check if in a bzr repository and optimize bzr calls in prompt_bzr
Diffstat (limited to 'themes')
-rw-r--r-- | themes/agnoster.zsh-theme | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 518a14a37..8c700d06a 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -140,24 +140,30 @@ prompt_git() { } prompt_bzr() { - (( $+commands[bzr] )) || return - if (bzr status >/dev/null 2>&1); then - status_mod=`bzr status | head -n1 | grep "modified" | wc -m` - status_all=`bzr status | head -n1 | wc -m` - revision=`bzr log | head -n2 | tail -n1 | sed 's/^revno: //'` - if [[ $status_mod -gt 0 ]] ; then - prompt_segment yellow black - echo -n "bzr@"$revision "✚ " - else - if [[ $status_all -gt 0 ]] ; then - prompt_segment yellow black - echo -n "bzr@"$revision - else - prompt_segment green black - echo -n "bzr@"$revision - fi - fi + (( $+commands[bzr] )) || return + + # Test if bzr repository in directory hierarchy + local dir="$PWD" + while [[ ! -d "$dir/.bzr" ]]; do + [[ "$dir" = "/" ]] && return + dir="${dir:h}" + done + + local bzr_status status_mod status_all revision + if bzr_status=$(bzr status 2>&1); then + status_mod=$(echo -n "$bzr_status" | head -n1 | grep "modified" | wc -m) + status_all=$(echo -n "$bzr_status" | head -n1 | wc -m) + revision=$(bzr log -r-1 --log-format line | cut -d: -f1) + if [[ $status_mod -gt 0 ]] ; then + prompt_segment yellow black "bzr@$revision ✚" + else + if [[ $status_all -gt 0 ]] ; then + prompt_segment yellow black "bzr@$revision" + else + prompt_segment green black "bzr@$revision" + fi fi + fi } prompt_hg() { |