From 29e83a2dcb9d53a68af34f0a290f0d33f5a44d56 Mon Sep 17 00:00:00 2001 From: pvincent Date: Sun, 7 Jul 2019 12:27:29 +0400 Subject: [PATCH] git ahead count --- bash.bashrc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/bash.bashrc b/bash.bashrc index 4d2257a..b9cdce5 100644 --- a/bash.bashrc +++ b/bash.bashrc @@ -78,16 +78,23 @@ __prompt_command() { if hash git 2>&-; then # git command exists + if git rev-parse --git-dir > /dev/null 2>&1; then # current dir is version controlled - branch=$(git branch 2> /dev/null | grep -e ^* | cut -d ' ' -f2) + local branch=$(git branch 2> /dev/null | grep -e ^* | cut -d ' ' -f2) PS1+=" ${R}[${Mag}${branch}${R}|" - dirty=$(git status -s | wc -l) - if [ $dirty == 0 ]; then - PS1+="${Gre}✔" - else + local dirty=$(git status -s | wc -l) + if [ $dirty > 0 ]; then PS1+="${Mag}…$dirty" + else + local ahead=$(git rev-list --branches --not --remotes) + echo $ahead + if [ $ahead > 0 ]; then + PS1+="${Blu}↑${ahead}" + else + PS1+="${Gre}✔" + fi fi PS1+="${R}]" fi