diff --git a/lib/git.zsh b/lib/git.zsh index fb4ad8ca6..d6b5b37a5 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -1,7 +1,7 @@ # get the name of the branch we are on function git_prompt_info() { ref=$(git symbolic-ref HEAD 2> /dev/null) || return - echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" + echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$(git_prompt_ahead)$ZSH_THEME_GIT_PROMPT_SUFFIX" } @@ -21,7 +21,7 @@ parse_git_dirty() { # Checks if there are commits ahead from remote function git_prompt_ahead() { - if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then + if $(echo "$(git log $(git_current_upstream)/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then echo "$ZSH_THEME_GIT_PROMPT_AHEAD" fi } diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index e1d682508..9da2f449e 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -54,10 +54,15 @@ function current_branch() { echo ${ref#refs/heads/} } +function git_current_upstream(){ + local upstream=$(git config --get branch."$(current_branch)".remote) || return + echo $upstream +} + # these aliases take advantage of the previous function alias ggpull='git pull origin $(current_branch)' compdef ggpull=git alias ggpush='git push origin $(current_branch)' compdef ggpush=git alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)' -compdef ggpnp=git \ No newline at end of file +compdef ggpnp=git