a9061f34d7dbb2e65d2c378dcee9402466ab63ae

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #2633 from redsunsoft/agnoster-theme-git-mode-addition

Added git support for merging, rebasing, and bisecting to agnoster theme

Diff

 1diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme
 2index 85b846cb5bd9156b24cb57f7d0b05084af8339ea..2b33c48bc7bc2cec58bad4ecff372026c2a023e1 100644
 3--- a/themes/agnoster.zsh-theme
 4+++ b/themes/agnoster.zsh-theme
 5@@ -69,7 +69,9 @@ prompt_context() {
 6 
 7 # Git: branch/detached head, dirty status
 8 prompt_git() {
 9-  local ref dirty
10+  local ref dirty mode repo_path
11+  repo_path=$(git rev-parse --git-dir 2>/dev/null)
12+
13   if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
14     dirty=$(parse_git_dirty)
15     ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)"
16@@ -79,6 +81,14 @@ prompt_git() {
17       prompt_segment green black
18     fi
19 
20+    if [[ -e "${repo_path}/BISECT_LOG" ]]; then
21+      mode=" <B>"
22+    elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then
23+      mode=" >M<"
24+    elif [[ -e "${repo_path}/rebase" || -e "${repo_path}/rebase-apply" || -e "${repo_path}/rebase-merge" || -e "${repo_path}/../.dotest" ]]; then
25+      mode=" >R>"
26+    fi
27+
28     setopt promptsubst
29     autoload -Uz vcs_info
30 
31@@ -90,7 +100,7 @@ prompt_git() {
32     zstyle ':vcs_info:*' formats ' %u%c'
33     zstyle ':vcs_info:*' actionformats ' %u%c'
34     vcs_info
35-    echo -n "${ref/refs\/heads\// }${vcs_info_msg_0_%% }"
36+    echo -n "${ref/refs\/heads\// }${vcs_info_msg_0_%% }${mode}"
37   fi
38 }
39