From 007f7a7e265fce0702ebbaca49af155ea15d6f3c Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Tue, 8 Nov 2022 20:13:19 -0500 Subject: [PATCH] Colors support for git ahead/behind. --- tcshrc.prompt.colors | 2 ++ tcshrc.prompt.final | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/tcshrc.prompt.colors b/tcshrc.prompt.colors index 0b34b25..0ef8724 100644 --- a/tcshrc.prompt.colors +++ b/tcshrc.prompt.colors @@ -19,6 +19,8 @@ set depth_color="ansi:3" set percent_color="ansi:6" #${csi}3;4;38;2;255;192;192;58;2;255;255;255m%} set branch_color="underline italic ffc0c0 ul:white" +set ahead_tracking_color="9f9" +set behind_tracking_color="f99" alias load_default_prompt_colors source ${CSHENV_DIR}/tcshrc.prompt.colors diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index 04c024a..c35c20f 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -25,6 +25,21 @@ if( "${curr_branch_color}" != "${branch_color}" ) then set branch_color_seq="%{[`__build_sgr_code no-csi reset ${curr_branch_color}`m" endif +if( ! $?curr_ahead_tracking_color ) then + set curr_ahead_tracking_color=impossible +endif +if( "${curr_ahead_tracking_color}" != "${ahead_tracking_color}" ) then + set curr_ahead_tracking_color="${ahead_tracking_color}" + set ahead_tracking_color_seq="^[[`__build_sgr_code no-csi reset ${curr_ahead_tracking_color}`m" +endif + +if( ! $?curr_behind_tracking_color ) then + set curr_behind_tracking_color=impossible +endif +if( "${curr_behind_tracking_color}" != "${behind_tracking_color}" ) then + set curr_behind_tracking_color="${behind_tracking_color}" + set behind_tracking_color_seq="^[[`__build_sgr_code no-csi reset ${curr_behind_tracking_color}`m" +endif if( ! $?curr_percent_color ) then set curr_percent_color=impossible @@ -270,13 +285,13 @@ if( 0 == ${__res} ) then set git_ahead_count=`git rev-list --count --right-only \@\{upstream\}..HEAD` #echo "Got: ${git_ahead_count}" if( 0 != ${git_behind_count} ) then - set git_tracking_stat=" -${git_behind_count}" + set git_tracking_stat=": -%{${behind_tracking_color_seq}%}${git_behind_count}%{${sgr_reset}%}" if( 0 != ${git_ahead_count} ) then - set git_tracking_stat="${git_tracking_stat},+${git_ahead_count}" + 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=" +${git_ahead_count}" + set git_tracking_stat=": %{${ahead_tracking_color_seq}%}${git_ahead_count}%{${sgr_reset}%}" endif endif endif