Make git ahead and behind use one command.

This reduces the number of forks per command line in git directories.
This commit is contained in:
2026-06-29 10:17:38 -04:00
parent ea96ee93f6
commit c4d61bb293
+20 -26
View File
@@ -164,37 +164,31 @@ set __res=$?
if( 0 == ${__res} ) then if( 0 == ${__res} ) then
set git_branch=`git branch --show-current -q` >& /dev/null set git_branch=`git branch --show-current -q` >& /dev/null
if( ! -z "${git_branch}" ) then if( ! -z "${git_branch}" ) then
set branch_space=30 set git_counts=(`git rev-list --count --left-right \@\{upstream\}..HEAD`)
set branch_indent=16 _debug "Got: ${git_counts}"
#set git_branch_reserve=`echo ${git_branch} | wc -c` >& /dev/null
#set git_prompt="%{${csi}${branch_indent}C${csi}mBranch: ${csi}3;38;2;255;192;192m${git_branch}${csi}m${csi}${branch_space}C\n%}"
set git_behind_count=${git_counts[1]}
set git_ahead_count=${git_counts[2]}
#@ git_behind_count = ${git_behind_count} + 1
_debug "Got: ${git_behind_count}"
_debug "Got: ${git_ahead_count}"
@ git_count_check = ${git_ahead_count} + ${git_behind_count}
if( 0 != ${git_count_check} ) then
set git_tracking_stat=": "
git rev-list --count --left-right \@\{upstream\}..HEAD>&/dev/null if( 0 != ${git_behind_count} ) then
set __res=$? set git_tracking_stat="${git_tracking_stat}-%{${behind_tracking_color_seq}%}${git_behind_count}%{${sgr_reset}%}"
#echo "Got: ${git_counts}" endif
if( 0 == ${__res} ) then if( 0 != ${git_ahead_count} ) then
set git_behind_count=`git rev-list --count --right-only HEAD..\@\{upstream\}` if( ${git_behind_count} != 0 ) then
#echo "Got: ${git_behind_count}" set git_tracking_stat="${git_tracking_stat},"
set git_ahead_count=`git rev-list --count --right-only \@\{upstream\}..HEAD` endif
#echo "Got: ${git_ahead_count}" set git_tracking_stat="${git_tracking_stat}+%{${ahead_tracking_color_seq}%}${git_ahead_count}%{${sgr_reset}%}"
if( 0 != ${git_behind_count} ) then endif
set git_tracking_stat=": -%{${behind_tracking_color_seq}%}${git_behind_count}%{${sgr_reset}%}" endif
if( 0 != ${git_ahead_count} ) then
set git_tracking_stat="${git_tracking_stat},+%{${ahead_tracking_color_seq}%}${git_ahead_count}%{${sgr_reset}%}"
endif
else
if( 0 != ${git_ahead_count} ) then
set git_tracking_stat=": +%{${ahead_tracking_color_seq}%}${git_ahead_count}%{${sgr_reset}%}"
endif
endif
endif
set git_prompt="%{${sgr_reset}%}(${branch_symbol} %{${branch_color_seq}%}${git_branch}%{${sgr_reset}%}${git_tracking_stat}) " set git_prompt="%{${sgr_reset}%}(${branch_symbol} %{${branch_color_seq}%}${git_branch}%{${sgr_reset}%}${git_tracking_stat}) "
#set git_prompt="%{${csi}10D${csi}2D(xyz${git_branch})${csi}m%%}"
#set git_prompt="%{${csi}0;35m${csi}50D${git_branch} %}"
endif endif
else
endif endif
#set prompt_cool="%{\n%}${align_prefix}${battery_prefix}${battery_prompt}${date_prompt}${align_suffix}${git_prompt}${brace_color_seq}\[${prompt_reference}${line_prompt}${depth_prompt}${user_prompt}${at_color_seq}@${host_prompt}${text_color_seq}\: ${path_prompt}${brace_color_seq}\]${end_prompt}" #set prompt_cool="%{\n%}${align_prefix}${battery_prefix}${battery_prompt}${date_prompt}${align_suffix}${git_prompt}${brace_color_seq}\[${prompt_reference}${line_prompt}${depth_prompt}${user_prompt}${at_color_seq}@${host_prompt}${text_color_seq}\: ${path_prompt}${brace_color_seq}\]${end_prompt}"