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 ++++++++++++++++++++++++++-------------- 11_Colors.zsh | 5 +++-- 12_Prompts.zsh | 14 +++++++------- 3 files changed, 36 insertions(+), 23 deletions(-) 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" diff --git a/11_Colors.zsh b/11_Colors.zsh index 055f28c..ada1fdb 100644 --- a/11_Colors.zsh +++ b/11_Colors.zsh @@ -81,11 +81,12 @@ __set_prompt_colors () _gcl_colors[init]="$color[black];$color[bold]" _gcl_colors[gitdir]="$color[red];$color[bold]" _gcl_colors[uptodate]="$_prompt_colors[generic]" + _gcl_colors[changed]="$color[green]" _gcl_colors[cached]="$color[yellow];$color[bold]" _gcl_colors[mixed]="$color[green];$color[bold]" - _gcl_colors[changed]="$color[green]" _gcl_colors[merging]="$color[bg-black]" - _gcl_colors[ffwd]="$color[standout]" + _gcl_colors[ffwd]="$color[red];$color[bold]" + _gcl_colors[diverged]="$color[black];$color[bold]" _guilt_colors[applied]=$_gcl_colors[cached] _guilt_colors[unapplied]=$color[black] diff --git a/12_Prompts.zsh b/12_Prompts.zsh index 7374bf2..55b816e 100644 --- a/12_Prompts.zsh +++ b/12_Prompts.zsh @@ -41,13 +41,13 @@ chpwd() __cmd_exists todo && todo - if ( __cmd_exists git && test -d .git ) - then - __debug -n " GIT check..." - # Shows tracked branches and modified files - git status | sed -n '2{/# Your branch/p;q}' - __debug - fi + #if ( __cmd_exists git && test -d .git ) + #then + # __debug -n " GIT check..." + # # Shows tracked branches and modified files + # git status | sed -n '2{/# Your branch/p;q}' + # __debug + #fi } preexec () -- cgit v1.2.3