From: Oleg Broytman Date: Mon, 14 Dec 2020 21:02:15 +0000 (+0300) Subject: bash_prompt: Show -behind/+ahead counters X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=a429d549424241eec8d686150b92eb7f047b7f10;p=dotfiles.git bash_prompt: Show -behind/+ahead counters --- diff --git a/admin/prog/bash_prompt b/admin/prog/bash_prompt index eb152c9..4e428f3 100644 --- a/admin/prog/bash_prompt +++ b/admin/prog/bash_prompt @@ -69,6 +69,22 @@ prompt_git() { git rev-parse --short HEAD 2> /dev/null || \ printf "(unknown)")" + up=`git rev-parse --abbrev-ref @{u} 2>/dev/null` + if [ -n "$up" ]; then + local left right + set -- `git rev-list --count --left-right @{u}...@` + left=$1 + right=$2 + if [ "$left" -gt 0 -o "$right" -gt 0 ]; then + if [ "$left" -gt 0 ]; then + s="$s-$left" + fi + if [ "$right" -gt 0 ]; then + s="$s+$right" + fi + fi + fi + [ -n "$s" ] && s=" $s" printf " (%s)" "$branchName$s" fi