Skip to content

Instantly share code, notes, and snippets.

@drKnoxy
Created May 8, 2018 19:12
Show Gist options
  • Save drKnoxy/11cbc9ecb90d5f402faf83c55416d0f2 to your computer and use it in GitHub Desktop.
Save drKnoxy/11cbc9ecb90d5f402faf83c55416d0f2 to your computer and use it in GitHub Desktop.
Adding the upstream branch to your zsh pure theme
# Nothing to do if we aren't in a git repo
if git rev-parse --git-dir > /dev/null 2>&1; then
# Get the name of upstream
upstream=$(command git rev-parse --symbolic-full-name --abbrev-ref @{u} 2>/dev/null)
# Check if we have an upstream, and that it is different than our current branch
if [[
$(command git rev-parse --symbolic-full-name --abbrev-ref @{u} 2>/dev/null | sed 's/origin\///')
!= $(command git rev-parse --abbrev-ref HEAD)
&& ! -z "$upstream"
]]; then
upstreamText=" [${upstream}]"
fi
fi
# Add upstream text to the prompt
preprompt+="%F{$git_color}${vcs_info_msg_0_}${prompt_pure_git_dirty}${upstreamText}%f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment