Reduce git invocations for prompt gen.

This commit is contained in:
2026-07-08 00:31:00 -04:00
parent 93153525e8
commit bcb388407c
+25 -9
View File
@@ -164,18 +164,30 @@ endif
set git_prompt="" set git_prompt=""
set git_prefix="" set git_prefix=""
set git_tracking_stat="" set git_tracking_stat=""
set git_repo=`git rev-parse --git-dir >& /dev/null` set git_branch=(`git branch --show-current -q |&cat`)
set __res=$? if( ${#git_branch} <= 1 ) then
if( 0 == ${__res} ) then _debug "We see git branch |${git_branch}|"
set git_branch=`git branch --show-current -q` >& /dev/null if( ${#git_branch} == 0 ) then
if( ! -z "${git_branch}" ) then _debug "We see git branch with no elements, clearing..."
set git_counts=(`git rev-list --count --left-right \@\{upstream\}..HEAD`) set git_branch_name="???"
else
set git_branch_name="${git_branch[1]}"
_debug "We see git branch with one element, using... (${git_branch[1]}-${git_branch_name})"
endif
set git_prompt="%{${sgr_reset}%}(${branch_symbol} %{${branch_color_seq}%}${git_branch_name}%{${sgr_reset}%}"
if( "${#git_branch}" == 1 ) then
_debug "We see git branch |${git_branch[1]}|"
_debug "Doing Rev List"
set git_counts=`git rev-list --count --left-right \@\{upstream\}..HEAD|&cat`
_debug "Done with Rev List"
_debug "Got: ${git_counts}" _debug "Got: ${git_counts}"
set git_tracking_stat=""
if ( ${#git_counts} == 2 ) then
set git_behind_count=${git_counts[1]} set git_behind_count=${git_counts[1]}
set git_ahead_count=${git_counts[2]} set git_ahead_count=${git_counts[2]}
#@ git_behind_count = ${git_behind_count} + 1 #@ git_behind_count = ${git_behind_count} + 1
_debug "Got: ${git_behind_count}" echo "Got: ${git_behind_count}"
_debug "Got: ${git_ahead_count}" _debug "Got: ${git_ahead_count}"
@ git_count_check = ${git_ahead_count} + ${git_behind_count} @ git_count_check = ${git_ahead_count} + ${git_behind_count}
if( 0 != ${git_count_check} ) then if( 0 != ${git_count_check} ) then
@@ -191,9 +203,13 @@ if( 0 == ${__res} ) then
set git_tracking_stat="${git_tracking_stat}+%{${ahead_tracking_color_seq}%}${git_ahead_count}%{${sgr_reset}%}" set git_tracking_stat="${git_tracking_stat}+%{${ahead_tracking_color_seq}%}${git_ahead_count}%{${sgr_reset}%}"
endif endif
endif endif
set git_prompt="%{${sgr_reset}%}(${branch_symbol} %{${branch_color_seq}%}${git_branch}%{${sgr_reset}%}${git_tracking_stat}) "
endif endif
set git_prompt="${git_prompt}${git_tracking_stat}"
else
set git_prompt="${git_prompt}"
endif
set git_prompt="${git_prompt}) "
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}"