From a429d549424241eec8d686150b92eb7f047b7f10 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Tue, 15 Dec 2020 00:02:15 +0300 Subject: [PATCH] bash_prompt: Show -behind/+ahead counters --- admin/prog/bash_prompt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 -- 2.39.5