Reduce git invocations for prompt gen.
This commit is contained in:
+38
-22
@@ -164,36 +164,52 @@ 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_behind_count=${git_counts[1]}
|
set git_tracking_stat=""
|
||||||
set git_ahead_count=${git_counts[2]}
|
if ( ${#git_counts} == 2 ) then
|
||||||
#@ git_behind_count = ${git_behind_count} + 1
|
set git_behind_count=${git_counts[1]}
|
||||||
_debug "Got: ${git_behind_count}"
|
set git_ahead_count=${git_counts[2]}
|
||||||
_debug "Got: ${git_ahead_count}"
|
#@ git_behind_count = ${git_behind_count} + 1
|
||||||
@ git_count_check = ${git_ahead_count} + ${git_behind_count}
|
echo "Got: ${git_behind_count}"
|
||||||
if( 0 != ${git_count_check} ) then
|
_debug "Got: ${git_ahead_count}"
|
||||||
set git_tracking_stat=": "
|
@ git_count_check = ${git_ahead_count} + ${git_behind_count}
|
||||||
|
if( 0 != ${git_count_check} ) then
|
||||||
|
set git_tracking_stat=": "
|
||||||
|
|
||||||
if( 0 != ${git_behind_count} ) then
|
if( 0 != ${git_behind_count} ) then
|
||||||
set git_tracking_stat="${git_tracking_stat}-%{${behind_tracking_color_seq}%}${git_behind_count}%{${sgr_reset}%}"
|
set git_tracking_stat="${git_tracking_stat}-%{${behind_tracking_color_seq}%}${git_behind_count}%{${sgr_reset}%}"
|
||||||
endif
|
endif
|
||||||
if( 0 != ${git_ahead_count} ) then
|
if( 0 != ${git_ahead_count} ) then
|
||||||
if( ${git_behind_count} != 0 ) then
|
if( ${git_behind_count} != 0 ) then
|
||||||
set git_tracking_stat="${git_tracking_stat},"
|
set git_tracking_stat="${git_tracking_stat},"
|
||||||
|
endif
|
||||||
|
set git_tracking_stat="${git_tracking_stat}+%{${ahead_tracking_color_seq}%}${git_ahead_count}%{${sgr_reset}%}"
|
||||||
endif
|
endif
|
||||||
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}) "
|
set git_prompt="${git_prompt}${git_tracking_stat}"
|
||||||
|
else
|
||||||
|
set git_prompt="${git_prompt}"
|
||||||
endif
|
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}"
|
||||||
|
|||||||
Reference in New Issue
Block a user