From 56f2fd9c0446a2a77322ed0270ac9d8778a1d489 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Thu, 1 Aug 2013 15:15:28 +0200 Subject: [Git] Better ahead/behind/diverged managment --- 01_Internal.zsh | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to '01_Internal.zsh') diff --git a/01_Internal.zsh b/01_Internal.zsh index 0673915..575cc3e 100644 --- a/01_Internal.zsh +++ b/01_Internal.zsh @@ -244,22 +244,32 @@ __get_git_branch () local _ahead=0 ; local _behind=0 ; eval $(git status . | sed -n ' - /^#$/ { q } + /^#$/ { q } s/^# and have \([0-9]\+\) and \([0-9]\+\) different.*/_ahead=\1;\n_behind=\2;\n/p ; s/^# Your branch is \(behind\|ahead\) .* \([0-9]\+\) commit.*/_\1=\2;\n/p ; ') + # ᛨ ᛪ ⇅ ↟↟ ⇶ ⇶ ⇵ ⌥ ⬆ ⬇ ⬌ ⬍ ⤱ ⤲ ✖ ➠ ➟ ⤴ ⎇⬋⬉⬉⬈⬌⬍⬅⬄ + [ $(($_ahead + $_behind)) -gt 0 ] && my_git_branch+=" " - if [ $_ahead -gt 0 ] - then - my_git_branch+=$C_$_gcl_colors[cached]$_C"↑"$C_$_prompt_colors[soft_generic]$_C - [ $_ahead -gt 1 ] && my_git_branch+="₊$(echo $_ahead | _subscript_number)" - fi - if [ $_behind -gt 0 ] - then - my_git_branch+=$C_$_prompt_colors[bold_generic]";"$color[blink]$_C"↓"$C_$_prompt_colors[bold_generic]$_C - [ $_behind -gt 1 ] && my_git_branch+="₊$(echo $_behind | _subscript_number)" - fi + + if [ $_ahead -gt 0 -a $_behind -gt 0 ] + then + my_git_branch+=$C_$_gcl_colors[diverged]$_C + my_git_branch+="✖ " + fi + if [ $_behind -gt 0 ] + then + my_git_branch+=$C_$_gcl_colors[ffwd]$_C + [ $_behind -gt 1 ] && my_git_branch+="$(echo $_behind | _subscript_number)" + my_git_branch+="⬇" + fi + if [ $_ahead -gt 0 ] + then + my_git_branch+=$C_$_gcl_colors[cached]$_C + my_git_branch+="⬆" + [ $_ahead -gt 1 ] && my_git_branch+="$(echo $_ahead | _subscript_number)" + fi fi echo $my_git_branch @@ -364,12 +374,14 @@ __get_git_status () __debug - __debug -n " merges..." - if [ $(git status . | sed -n '2{/can be fast-forwarded/p;/have diverged/p;q}' | wc -l) -gt 0 ] + __debug -n " diverged..." + if [ $(git status . | sed -n '2{/have diverged/p;q}' | wc -l) -gt 0 ] then - my_git_status+=";$_gcl_colors[ffwd]" + my_git_status+=";$color[standout]" fi + __debug + __debug -n " merges..." if [ $(git ls-files --unmerged | wc -l) -gt 0 ] then my_git_status="${_gcl_colors[merging]:+$_gcl_colors[merging];}$my_git_status" -- cgit v1.2.3