diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index 3357705..88de7ab 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -164,36 +164,52 @@ endif set git_prompt="" set git_prefix="" set git_tracking_stat="" -set git_repo=`git rev-parse --git-dir >& /dev/null` -set __res=$? -if( 0 == ${__res} ) then - set git_branch=`git branch --show-current -q` >& /dev/null - if( ! -z "${git_branch}" ) then - set git_counts=(`git rev-list --count --left-right \@\{upstream\}..HEAD`) +set git_branch=(`git branch --show-current -q |&cat`) +if( ${#git_branch} <= 1 ) then + _debug "We see git branch |${git_branch}|" + if( ${#git_branch} == 0 ) then + _debug "We see git branch with no elements, clearing..." + 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}" - 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=": " + set git_tracking_stat="" + if ( ${#git_counts} == 2 ) then + set git_behind_count=${git_counts[1]} + set git_ahead_count=${git_counts[2]} + #@ git_behind_count = ${git_behind_count} + 1 + echo "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=": " - if( 0 != ${git_behind_count} ) then - set git_tracking_stat="${git_tracking_stat}-%{${behind_tracking_color_seq}%}${git_behind_count}%{${sgr_reset}%}" - endif - if( 0 != ${git_ahead_count} ) then - if( ${git_behind_count} != 0 ) then - set git_tracking_stat="${git_tracking_stat}," + if( 0 != ${git_behind_count} ) then + set git_tracking_stat="${git_tracking_stat}-%{${behind_tracking_color_seq}%}${git_behind_count}%{${sgr_reset}%}" + endif + if( 0 != ${git_ahead_count} ) then + if( ${git_behind_count} != 0 ) then + 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 - set git_tracking_stat="${git_tracking_stat}+%{${ahead_tracking_color_seq}%}${git_ahead_count}%{${sgr_reset}%}" 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 + set git_prompt="${git_prompt}) " 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}"