More detailed git prompt information.

Possibility to also display if a branch is behind, has diverged or is up-to-date.
Also changed the implementation to use git-rev-list which is a bit easier than
git-log.
This commit is contained in:
Jan Gosmann 2012-02-25 22:43:40 +01:00
commit 303fb7286c

View file

@ -22,8 +22,16 @@ 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
echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
ahead=$(git rev-list origin/$(current_branch)..HEAD -- 2> /dev/null)
behind=$(git rev-list HEAD..origin/$(current_branch) -- 2> /dev/null)
if [[ -n $ahead && -n $behind ]]; then
echo "$ZSH_THEME_GIT_PROMPT_DIVERGED"
elif [[ -n $ahead ]]; then
echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
elif [[ -n $behind ]]; then
echo "$ZSH_THEME_GIT_PROMPT_BEHIND"
else
echo "$ZSH_THEME_GIT_PROMPT_UPTODATE"
fi
}