]> arthur.barton.de Git - ax-zsh.git/commitdiff
git: Split git_prompt() into git_prompt_info() and git_prompt_status()
authorAlexander Barton <alex@barton.de>
Tue, 5 Feb 2019 19:14:31 +0000 (20:14 +0100)
committerAlexander Barton <alex@barton.de>
Tue, 5 Feb 2019 19:14:35 +0000 (20:14 +0100)
This is more in line to OhMyZsh, which some themes depend on.

plugins/git/git.zshrc

index 7c6e651f6098e225b81fd163f32a8aa04479134a..55c395f6b887caa0c74ae2e77c5681a334c4f028 100644 (file)
@@ -36,16 +36,23 @@ git_prompt_behind() {
                && echo "$ZSH_THEME_VCS_PROMPT_BEHIND"
 }
 
+git_prompt_info() {
+       local ref=$(git symbolic-ref HEAD 2>/dev/null) || return 1
+       echo "${ref#refs/heads/}"
+}
+git_prompt_status() {
+       echo "$(git_parse_dirty)$(git_prompt_ahead)$(git_prompt_behind)"
+}
+
 git_prompt() {
-       ref=$(git symbolic-ref HEAD 2>/dev/null) || return 1
-       echo "${ref#refs/heads/}$(git_parse_dirty)$(git_prompt_ahead)$(git_prompt_behind)"
+       local prompt=$(git_prompt_info)
+       [[ -n "$prompt" ]] || return 0
+       echo "$prompt$(git_prompt_status)"
        return 0
 }
 
 # OhMyZsh compatibility functions
-alias git_prompt_info=git_prompt
 alias parse_git_dirty=git_parse_dirty
-alias git_prompt_status=git_prompt
 
 ax_vcs_prompt_functions=($ax_vcs_prompt_functions git_prompt)