diff --git a/prompt.sh b/prompt.sh index 46e2965..23740b6 100644 --- a/prompt.sh +++ b/prompt.sh @@ -92,15 +92,9 @@ function build_prompt { can_fast_forward=false commits_diff=$(git log --pretty=oneline --topo-order --left-right ${current_commit_hash}...${upstream} 2> /dev/null) - commits_ahead=0 - commits_behind=0 - if [[ $commits_diff =~ .*^\<(..) ]]; then - commits_ahead=${#BASH_REMATCH[@]} - fi - if [[ $commits_diff =~ .*^\>(..) ]]; then - commits_behind=${#BASH_REMATCH[@]} - fi + commits_ahead=$(git log --pretty=oneline --topo-order --left-right ${current_commit_hash}...${upstream} | grep -c "^<" ) + commits_behind=$(git log --pretty=oneline --topo-order --left-right ${current_commit_hash}...${upstream} | grep -c "^>" ) if [[ $commits_ahead -gt 0 && $commits_behind -gt 0 ]]; then has_diverged=true