From 430a7e8b0e0b3f50a2b3cae9d1ae20ed9c68befe Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 4 Jun 2022 13:15:10 -0400 Subject: [PATCH 01/13] I've started the process of redesigning the colours. --- tcshrc.colors | 1 + tcshrc.prompt.colors | 9 +++------ tcshrc.prompt.defs | 8 ++++---- tcshrc.prompt.final | 33 +++++++++++++++++++++++++++++++-- 4 files changed, 39 insertions(+), 12 deletions(-) diff --git a/tcshrc.colors b/tcshrc.colors index 79a890b..2aea2e3 100644 --- a/tcshrc.colors +++ b/tcshrc.colors @@ -80,6 +80,7 @@ set bright_white="$csi$ansi_bright;$ansi_white$ansi_color" # You process true colour by evaluating `__make_color_sequence` on the environment variable. alias __make_color_sequence ${CSHENV_DIR}/bin/__hex_to_ansi +set sgr_reset="[`__build_sgr_code no-csi reset`m" ########################### # vim:filetype=tcsh diff --git a/tcshrc.prompt.colors b/tcshrc.prompt.colors index 0efd294..ad66e21 100644 --- a/tcshrc.prompt.colors +++ b/tcshrc.prompt.colors @@ -3,15 +3,15 @@ ###################### -set date_color="${dim_magenta}" -set time_color="${bright_magenta}" +set date_color="ansi:5" +set time_color="ansi:13" set text_color="${bright_white}" set oldp_color="${dim}" set brace_color="${bright_yellow}" set host_color="${bright_blue}" set name_color="${bright_cyan}" set at_color="${dim_cyan}" -set path_color="${bright_green}" +set path_color="ansi:10" set line_color="${dim_red}" set prompt_color="${dim}" set depth_color="${dim_yellow}" @@ -20,15 +20,12 @@ set command_color="${dim}" set color_start="%{" set color_end="%}" -set date_color_seq="${color_start}${date_color}${color_end}" -set time_color_seq="${color_start}${time_color}${color_end}" set text_color_seq="${color_start}${text_color}${color_end}" set oldp_color_seq="${color_start}${oldp_color}${color_end}" set brace_color_seq="${color_start}${brace_color}${color_end}" set host_color_seq="${color_start}${host_color}${color_end}" set name_color_seq="${color_start}${name_color}${color_end}" set at_color_seq="${color_start}${at_color}${color_end}" -set path_color_seq="${color_start}${path_color}${color_end}" set line_color_seq="${color_start}${line_color}${color_end}" set prompt_color_seq="${color_start}${prompt_color}${color_end}" set depth_color_seq="${color_start}${depth_color}${color_end}" diff --git a/tcshrc.prompt.defs b/tcshrc.prompt.defs index 3e01620..6b038fa 100644 --- a/tcshrc.prompt.defs +++ b/tcshrc.prompt.defs @@ -19,6 +19,7 @@ if( ! $?unknown_tty ) then endif + # R G Y B C M set reference_colors=( ${csi}91m ${csi}92m ${csi}93m ${csi}38\;5\;33m ${csi}95m ${csi}96m ) @@ -112,9 +113,8 @@ set prompt_simple="${oldp_color_seq}[%n@%m: %c]%# " set align_prefix="%{${csi}A${csi}1000000G${csi}18D%}" set align_suffix="%{${csi}G${csi}1B%}" #set screen_return="%{8%}" -set date_prompt_core="${date_color_seq}%{%Y-%W-%D %}${time_color_seq}%{%P%}" -set date_prompt_left="${date_prompt_core}" -set date_prompt="${date_prompt_core}" +set date_prompt="%{%Y-%W-%D%}" +set time_prompt="%{%P%}" #unset edit if( $?CSHENV_DEBUG ) then @@ -128,7 +128,7 @@ set depth_prompt="${depth_color_seq}(${shlvl})" set line_prompt="${line_color_seq}`tty | sed -e 's;/dev/tty;;' -e 's;/dev/pts/;p/;' -e 's;/dev/;;' -e 's/not a tty/${unknown_tty}/'`" set user_prompt="${name_color_seq}%n" set host_prompt="${host_color_seq}${CSHENV_HOSTNAME}" -set path_prompt="${path_color_seq}%c02" +set path_prompt="%c02" set end_prompt="${prompt_color_seq}%#${command_color_seq} " alias oldp 'set prompt="$prompt_simple"; set cshenv_user_prompt_override' diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index 3043893..33cae13 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -1,6 +1,34 @@ ############################ ### Final Prompt Setting ### ############################ + +# Recompute cached sgr codes from any configuration updates +if( ! $?curr_path_color ) then + set curr_path_color=impossible +endif +if( ! $?curr_path_color || "${curr_path_color}" != "${path_color}" ) then + set curr_path_color="${path_color}" + set path_color_seq="[`__build_sgr_code no-csi reset ${curr_path_color}`m" +endif + +if( ! $?curr_date_color ) then + set curr_date_color=impossible +endif +if( ! $?curr_date_color || "${curr_date_color}" != "${date_color}" ) then + set curr_date_color="${date_color}" + set date_color_seq="[`__build_sgr_code no-csi reset ${curr_date_color}`m" + set date_prompt_view="%{${date_color_seq}%}${date_prompt}%{${sgr_reset}%}" +endif + +if( ! $?curr_time_color ) then + set curr_time_color=impossible +endif +if( ! $?curr_time_color || "${curr_time_color}" != "${time_color}" ) then + set curr_time_color="${time_color}" + set time_color_seq="[`__build_sgr_code no-csi reset ${curr_time_color}`m" + set time_prompt_view="%{${time_color_seq}%}${time_prompt}%{${sgr_reset}%}" +endif + if( ${prompt_hcolor} != 0 ) then set last_color = ${reference_colors[${prompt_hcolor}]} endif @@ -18,6 +46,7 @@ set medium_battery_level = 50 set strong_battery_level = 75 + while( ${prompt_hcolor} == 0 ) if( $?CSHENV_DEBUG ) then echo colorshuffle @@ -188,10 +217,10 @@ if( ! $?CSHENV_DISABLE_PROMPT_GIT ) then set git_prompt_view="${git_prompt}" endif if( ! $?CSHENV_DISABLE_PROMPT_PATH ) then - set path_prompt_view="${path_prompt}" + set path_prompt_view="%{${path_color_seq}%}${path_prompt}%{${sgr_reset}%}" endif -set prompt_cool="%{\n%}${align_prefix}${battery_prefix}${battery_prompt}${date_prompt}${align_suffix}${brace_color_seq}\[${prompt_reference_view}${line_prompt_view}${depth_prompt_view}${line_spacer_view}${user_prompt_view}${at_view}${host_prompt_view}${git_prompt_view}${path_prompt_view}${brace_color_seq}\]${end_prompt}" +set prompt_cool="%{\n%}${align_prefix}${battery_prefix}${battery_prompt}${date_prompt_view}%{ %}${time_prompt_view}${align_suffix}${brace_color_seq}\[${prompt_reference_view}${line_prompt_view}${depth_prompt_view}${line_spacer_view}${user_prompt_view}${at_view}${host_prompt_view}${git_prompt_view}${path_prompt_view}${brace_color_seq}\]${end_prompt}" From 8b398af6727aa7bdb78d3566f54774fb9df5f87f Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 4 Jun 2022 15:13:28 -0400 Subject: [PATCH 02/13] Did rework for `text_color` variable. --- tcshrc.prompt.colors | 3 +-- tcshrc.prompt.final | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/tcshrc.prompt.colors b/tcshrc.prompt.colors index ad66e21..1e27e5c 100644 --- a/tcshrc.prompt.colors +++ b/tcshrc.prompt.colors @@ -5,7 +5,7 @@ set date_color="ansi:5" set time_color="ansi:13" -set text_color="${bright_white}" +set text_color="reset" set oldp_color="${dim}" set brace_color="${bright_yellow}" set host_color="${bright_blue}" @@ -20,7 +20,6 @@ set command_color="${dim}" set color_start="%{" set color_end="%}" -set text_color_seq="${color_start}${text_color}${color_end}" set oldp_color_seq="${color_start}${oldp_color}${color_end}" set brace_color_seq="${color_start}${brace_color}${color_end}" set host_color_seq="${color_start}${host_color}${color_end}" diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index 33cae13..7c7bbe4 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -6,15 +6,15 @@ if( ! $?curr_path_color ) then set curr_path_color=impossible endif -if( ! $?curr_path_color || "${curr_path_color}" != "${path_color}" ) then +if( "${curr_path_color}" != "${path_color}" ) then set curr_path_color="${path_color}" - set path_color_seq="[`__build_sgr_code no-csi reset ${curr_path_color}`m" + set path_color_seq="%{[`__build_sgr_code no-csi reset ${curr_path_color}`m%}" endif if( ! $?curr_date_color ) then set curr_date_color=impossible endif -if( ! $?curr_date_color || "${curr_date_color}" != "${date_color}" ) then +if( "${curr_date_color}" != "${date_color}" ) then set curr_date_color="${date_color}" set date_color_seq="[`__build_sgr_code no-csi reset ${curr_date_color}`m" set date_prompt_view="%{${date_color_seq}%}${date_prompt}%{${sgr_reset}%}" @@ -23,12 +23,20 @@ endif if( ! $?curr_time_color ) then set curr_time_color=impossible endif -if( ! $?curr_time_color || "${curr_time_color}" != "${time_color}" ) then +if( "${curr_time_color}" != "${time_color}" ) then set curr_time_color="${time_color}" set time_color_seq="[`__build_sgr_code no-csi reset ${curr_time_color}`m" set time_prompt_view="%{${time_color_seq}%}${time_prompt}%{${sgr_reset}%}" endif +if( ! $?curr_text_color ) then + set curr_text_color=impossible +endif +if( "${curr_text_color}" != "${text_color}" ) then + set curr_text_color="${text_color}" + set text_color_seq="[`__build_sgr_code no-csi reset ${curr_text_color}`m" +endif + if( ${prompt_hcolor} != 0 ) then set last_color = ${reference_colors[${prompt_hcolor}]} endif @@ -186,7 +194,7 @@ if( ! $?CSHENV_DISABLE_PROMPT_SIGIL ) then endif if( ! $?CSHENV_DISABLE_PROMPT_TTY ) then set line_prompt_view="${line_prompt}" - set line_spacer_view="${text_color_seq}\- " + set line_spacer_view="%{${text_color_seq}%}\- " endif if( ! $?CSHENV_DISABLE_PROMPT_NESTING ) then set depth_prompt_spacing="" @@ -211,7 +219,7 @@ if( ! $?CSHENV_DISABLE_PROMPT_HOST ) then if( $?CSHENV_DISABLE_PROMPT_GIT && $?CSHENV_DISABLE_PROMPT_PATH ) then set host_prompt_tail="" endif - set host_prompt_view="${host_prompt}${text_color_seq}${host_prompt_tail}" + set host_prompt_view="${host_prompt}%{${text_color_seq}%}${host_prompt_tail}" endif if( ! $?CSHENV_DISABLE_PROMPT_GIT ) then set git_prompt_view="${git_prompt}" @@ -220,7 +228,7 @@ if( ! $?CSHENV_DISABLE_PROMPT_PATH ) then set path_prompt_view="%{${path_color_seq}%}${path_prompt}%{${sgr_reset}%}" endif -set prompt_cool="%{\n%}${align_prefix}${battery_prefix}${battery_prompt}${date_prompt_view}%{ %}${time_prompt_view}${align_suffix}${brace_color_seq}\[${prompt_reference_view}${line_prompt_view}${depth_prompt_view}${line_spacer_view}${user_prompt_view}${at_view}${host_prompt_view}${git_prompt_view}${path_prompt_view}${brace_color_seq}\]${end_prompt}" +set prompt_cool="%{\n%}${align_prefix}${battery_prefix}${battery_prompt}${date_prompt_view}%{ %}${time_prompt_view}${align_suffix}${brace_color_seq}\[${prompt_reference_view}${line_prompt_view}${depth_prompt_view}${line_spacer_view}${user_prompt_view}${at_view}${host_prompt_view}${git_prompt_view}${path_prompt_view}${brace_color_seq}\]${end_prompt}%{${text_color_seq}%}" From 286e9117f14e4d741d89518f5423bb7fa1bbffe3 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 4 Jun 2022 19:30:34 -0400 Subject: [PATCH 03/13] Host colour rewritten. --- tcshrc.prompt.colors | 3 +-- tcshrc.prompt.defs | 2 +- tcshrc.prompt.final | 10 +++++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tcshrc.prompt.colors b/tcshrc.prompt.colors index 1e27e5c..1a808c1 100644 --- a/tcshrc.prompt.colors +++ b/tcshrc.prompt.colors @@ -8,7 +8,7 @@ set time_color="ansi:13" set text_color="reset" set oldp_color="${dim}" set brace_color="${bright_yellow}" -set host_color="${bright_blue}" +set host_color="ansi:12" set name_color="${bright_cyan}" set at_color="${dim_cyan}" set path_color="ansi:10" @@ -22,7 +22,6 @@ set color_end="%}" set oldp_color_seq="${color_start}${oldp_color}${color_end}" set brace_color_seq="${color_start}${brace_color}${color_end}" -set host_color_seq="${color_start}${host_color}${color_end}" set name_color_seq="${color_start}${name_color}${color_end}" set at_color_seq="${color_start}${at_color}${color_end}" set line_color_seq="${color_start}${line_color}${color_end}" diff --git a/tcshrc.prompt.defs b/tcshrc.prompt.defs index 6b038fa..48edb9b 100644 --- a/tcshrc.prompt.defs +++ b/tcshrc.prompt.defs @@ -127,7 +127,7 @@ set depth_prompt="${depth_color_seq}(${shlvl})" #we "convert" pts/$number entries to ttypK entries? set line_prompt="${line_color_seq}`tty | sed -e 's;/dev/tty;;' -e 's;/dev/pts/;p/;' -e 's;/dev/;;' -e 's/not a tty/${unknown_tty}/'`" set user_prompt="${name_color_seq}%n" -set host_prompt="${host_color_seq}${CSHENV_HOSTNAME}" +set host_prompt="${CSHENV_HOSTNAME}" set path_prompt="%c02" set end_prompt="${prompt_color_seq}%#${command_color_seq} " diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index 7c7bbe4..0cecb6d 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -11,6 +11,14 @@ if( "${curr_path_color}" != "${path_color}" ) then set path_color_seq="%{[`__build_sgr_code no-csi reset ${curr_path_color}`m%}" endif +if( ! $?curr_host_color ) then + set curr_host_color=impossible +endif +if( "${curr_host_color}" != "${host_color}" ) then + set curr_host_color="${host_color}" + set host_color_seq="%{[`__build_sgr_code no-csi reset ${curr_host_color}`m%}" +endif + if( ! $?curr_date_color ) then set curr_date_color=impossible endif @@ -219,7 +227,7 @@ if( ! $?CSHENV_DISABLE_PROMPT_HOST ) then if( $?CSHENV_DISABLE_PROMPT_GIT && $?CSHENV_DISABLE_PROMPT_PATH ) then set host_prompt_tail="" endif - set host_prompt_view="${host_prompt}%{${text_color_seq}%}${host_prompt_tail}" + set host_prompt_view="${host_color_seq}${host_prompt}%{${text_color_seq}%}${host_prompt_tail}" endif if( ! $?CSHENV_DISABLE_PROMPT_GIT ) then set git_prompt_view="${git_prompt}" From b9764bd8a6bf800624ba520ab9d82eb7c4a9ccde Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sun, 5 Jun 2022 02:19:40 -0400 Subject: [PATCH 04/13] Now updated brace_color... --- tcshrc.prompt.colors | 3 +-- tcshrc.prompt.final | 11 ++++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tcshrc.prompt.colors b/tcshrc.prompt.colors index 1a808c1..866a8ee 100644 --- a/tcshrc.prompt.colors +++ b/tcshrc.prompt.colors @@ -7,7 +7,7 @@ set date_color="ansi:5" set time_color="ansi:13" set text_color="reset" set oldp_color="${dim}" -set brace_color="${bright_yellow}" +set brace_color="ansi:11" set host_color="ansi:12" set name_color="${bright_cyan}" set at_color="${dim_cyan}" @@ -21,7 +21,6 @@ set color_start="%{" set color_end="%}" set oldp_color_seq="${color_start}${oldp_color}${color_end}" -set brace_color_seq="${color_start}${brace_color}${color_end}" set name_color_seq="${color_start}${name_color}${color_end}" set at_color_seq="${color_start}${at_color}${color_end}" set line_color_seq="${color_start}${line_color}${color_end}" diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index 0cecb6d..9bfbd43 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -45,6 +45,15 @@ if( "${curr_text_color}" != "${text_color}" ) then set text_color_seq="[`__build_sgr_code no-csi reset ${curr_text_color}`m" endif +if( ! $?curr_brace_color ) then + set curr_brace_color=impossible +endif +if( "${curr_brace_color}" != "${brace_color}" ) then + set curr_brace_color="${brace_color}" + set brace_color_seq="%{[`__build_sgr_code no-csi reset ${curr_brace_color}`m%}" +endif + + if( ${prompt_hcolor} != 0 ) then set last_color = ${reference_colors[${prompt_hcolor}]} endif @@ -236,7 +245,7 @@ if( ! $?CSHENV_DISABLE_PROMPT_PATH ) then set path_prompt_view="%{${path_color_seq}%}${path_prompt}%{${sgr_reset}%}" endif -set prompt_cool="%{\n%}${align_prefix}${battery_prefix}${battery_prompt}${date_prompt_view}%{ %}${time_prompt_view}${align_suffix}${brace_color_seq}\[${prompt_reference_view}${line_prompt_view}${depth_prompt_view}${line_spacer_view}${user_prompt_view}${at_view}${host_prompt_view}${git_prompt_view}${path_prompt_view}${brace_color_seq}\]${end_prompt}%{${text_color_seq}%}" +set prompt_cool="%{\n%}${align_prefix}${battery_prefix}${battery_prompt}${date_prompt_view}%{ %}${time_prompt_view}${align_suffix}${brace_color_seq}\[%{${sgr_reset}%}${prompt_reference_view}${line_prompt_view}${depth_prompt_view}${line_spacer_view}${user_prompt_view}${at_view}${host_prompt_view}${git_prompt_view}${path_prompt_view}${brace_color_seq}\]%{${sgr_reset}%}${end_prompt}%{${text_color_seq}%}" From b96eb5ca34900c23bdafb1d1f6b51ef7f2184d5e Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sun, 5 Jun 2022 03:12:22 -0400 Subject: [PATCH 05/13] User name colour prompt updated. --- tcshrc.prompt.colors | 3 +-- tcshrc.prompt.defs | 2 +- tcshrc.prompt.final | 12 ++++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/tcshrc.prompt.colors b/tcshrc.prompt.colors index 866a8ee..bf159e7 100644 --- a/tcshrc.prompt.colors +++ b/tcshrc.prompt.colors @@ -9,7 +9,7 @@ set text_color="reset" set oldp_color="${dim}" set brace_color="ansi:11" set host_color="ansi:12" -set name_color="${bright_cyan}" +set user_color="ansi:14" set at_color="${dim_cyan}" set path_color="ansi:10" set line_color="${dim_red}" @@ -21,7 +21,6 @@ set color_start="%{" set color_end="%}" set oldp_color_seq="${color_start}${oldp_color}${color_end}" -set name_color_seq="${color_start}${name_color}${color_end}" set at_color_seq="${color_start}${at_color}${color_end}" set line_color_seq="${color_start}${line_color}${color_end}" set prompt_color_seq="${color_start}${prompt_color}${color_end}" diff --git a/tcshrc.prompt.defs b/tcshrc.prompt.defs index 48edb9b..452d8dd 100644 --- a/tcshrc.prompt.defs +++ b/tcshrc.prompt.defs @@ -126,7 +126,7 @@ set depth_prompt="${depth_color_seq}(${shlvl})" #we "convert" pts/$number entries to ttypK entries? set line_prompt="${line_color_seq}`tty | sed -e 's;/dev/tty;;' -e 's;/dev/pts/;p/;' -e 's;/dev/;;' -e 's/not a tty/${unknown_tty}/'`" -set user_prompt="${name_color_seq}%n" +set user_prompt="%n" set host_prompt="${CSHENV_HOSTNAME}" set path_prompt="%c02" set end_prompt="${prompt_color_seq}%#${command_color_seq} " diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index 9bfbd43..a5154a9 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -53,6 +53,14 @@ if( "${curr_brace_color}" != "${brace_color}" ) then set brace_color_seq="%{[`__build_sgr_code no-csi reset ${curr_brace_color}`m%}" endif +if( ! $?curr_user_color ) then + set curr_user_color=impossible +endif +if( "${curr_user_color}" != "${user_color}" ) then + set curr_user_color="${user_color}" + set user_color_seq="%{[`__build_sgr_code no-csi reset ${curr_user_color}`m%}" +endif + if( ${prompt_hcolor} != 0 ) then set last_color = ${reference_colors[${prompt_hcolor}]} @@ -199,7 +207,7 @@ endif set prompt_reference_view="" set line_prompt_view="" set depth_prompt_view="" -set user_prompt_view +set user_prompt_view="" set at_view="" set host_prompt_view="" set git_prompt_view="" @@ -226,7 +234,7 @@ if( ! $?CSHENV_DISABLE_PROMPT_NESTING ) then endif endif if( ! $?CSHENV_DISABLE_PROMPT_USER ) then - set user_prompt_view="${user_prompt}" + set user_prompt_view="${user_color_seq}${user_prompt}%{${sgr_reset}%}" if( ! $?CSHENV_DISABLE_PROMPT_HOST ) then set at_view="${at_color_seq}@" endif From 28ca17b30f0ac34e11219c55933f1dc3ec409994 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sun, 5 Jun 2022 03:23:13 -0400 Subject: [PATCH 06/13] Old prompt should just use an SGR reset. This makes it more simple. --- tcshrc.prompt.colors | 5 ----- tcshrc.prompt.defs | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/tcshrc.prompt.colors b/tcshrc.prompt.colors index bf159e7..20ec515 100644 --- a/tcshrc.prompt.colors +++ b/tcshrc.prompt.colors @@ -6,7 +6,6 @@ set date_color="ansi:5" set time_color="ansi:13" set text_color="reset" -set oldp_color="${dim}" set brace_color="ansi:11" set host_color="ansi:12" set user_color="ansi:14" @@ -20,16 +19,12 @@ set command_color="${dim}" set color_start="%{" set color_end="%}" -set oldp_color_seq="${color_start}${oldp_color}${color_end}" set at_color_seq="${color_start}${at_color}${color_end}" set line_color_seq="${color_start}${line_color}${color_end}" set prompt_color_seq="${color_start}${prompt_color}${color_end}" set depth_color_seq="${color_start}${depth_color}${color_end}" set command_color_seq="${color_start}${command_color}${color_end}" - -set oldp_color="${color_start}${dim_white}${color_end}" - ########################### # vim:filetype=tcsh ########################### diff --git a/tcshrc.prompt.defs b/tcshrc.prompt.defs index 452d8dd..b3df509 100644 --- a/tcshrc.prompt.defs +++ b/tcshrc.prompt.defs @@ -106,7 +106,7 @@ alias precmd 'source ${CSHENV_DIR}/tcshrc.prompt.final' set promptchars='%#' -set prompt_simple="${oldp_color_seq}[%n@%m: %c]%# " +set prompt_simple="%{${sgr_reset}%}[%n@%m: %c]%# " # Screens are almost certainly not a million chars wide. # If they are... oh well, that's a really weird one. From a9485b4b3bca30418cbc2ed8cc7ab222983cc4a5 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sun, 5 Jun 2022 12:35:21 -0400 Subject: [PATCH 07/13] Fixed up the prompt sigil itself. --- tcshrc.prompt.colors | 5 +---- tcshrc.prompt.defs | 2 +- tcshrc.prompt.final | 10 +++++++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/tcshrc.prompt.colors b/tcshrc.prompt.colors index 20ec515..f5d4f65 100644 --- a/tcshrc.prompt.colors +++ b/tcshrc.prompt.colors @@ -12,18 +12,15 @@ set user_color="ansi:14" set at_color="${dim_cyan}" set path_color="ansi:10" set line_color="${dim_red}" -set prompt_color="${dim}" +set prompt_color="reset" set depth_color="${dim_yellow}" -set command_color="${dim}" set color_start="%{" set color_end="%}" set at_color_seq="${color_start}${at_color}${color_end}" set line_color_seq="${color_start}${line_color}${color_end}" -set prompt_color_seq="${color_start}${prompt_color}${color_end}" set depth_color_seq="${color_start}${depth_color}${color_end}" -set command_color_seq="${color_start}${command_color}${color_end}" ########################### # vim:filetype=tcsh diff --git a/tcshrc.prompt.defs b/tcshrc.prompt.defs index b3df509..e0085e0 100644 --- a/tcshrc.prompt.defs +++ b/tcshrc.prompt.defs @@ -129,7 +129,7 @@ set line_prompt="${line_color_seq}`tty | sed -e 's;/dev/tty;;' -e 's;/dev/pts/;p set user_prompt="%n" set host_prompt="${CSHENV_HOSTNAME}" set path_prompt="%c02" -set end_prompt="${prompt_color_seq}%#${command_color_seq} " +set end_prompt="%#" alias oldp 'set prompt="$prompt_simple"; set cshenv_user_prompt_override' alias newp 'set prompt="$prompt_cool"; set cshenv_user_prompt_override' diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index a5154a9..be4daca 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -61,6 +61,14 @@ if( "${curr_user_color}" != "${user_color}" ) then set user_color_seq="%{[`__build_sgr_code no-csi reset ${curr_user_color}`m%}" endif +if( ! $?curr_prompt_color ) then + set curr_prompt_color=impossible +endif +if( "${curr_prompt_color}" != "${prompt_color}" ) then + set curr_prompt_color="${prompt_color}" + set prompt_color_seq="%{[`__build_sgr_code no-csi reset ${curr_prompt_color}`m%}" +endif + if( ${prompt_hcolor} != 0 ) then set last_color = ${reference_colors[${prompt_hcolor}]} @@ -253,7 +261,7 @@ if( ! $?CSHENV_DISABLE_PROMPT_PATH ) then set path_prompt_view="%{${path_color_seq}%}${path_prompt}%{${sgr_reset}%}" endif -set prompt_cool="%{\n%}${align_prefix}${battery_prefix}${battery_prompt}${date_prompt_view}%{ %}${time_prompt_view}${align_suffix}${brace_color_seq}\[%{${sgr_reset}%}${prompt_reference_view}${line_prompt_view}${depth_prompt_view}${line_spacer_view}${user_prompt_view}${at_view}${host_prompt_view}${git_prompt_view}${path_prompt_view}${brace_color_seq}\]%{${sgr_reset}%}${end_prompt}%{${text_color_seq}%}" +set prompt_cool="%{\n%}${align_prefix}${battery_prefix}${battery_prompt}${date_prompt_view}%{ %}${time_prompt_view}${align_suffix}${brace_color_seq}\[%{${sgr_reset}%}${prompt_reference_view}${line_prompt_view}${depth_prompt_view}${line_spacer_view}${user_prompt_view}${at_view}${host_prompt_view}${git_prompt_view}${path_prompt_view}${brace_color_seq}\]%{${sgr_reset}%}${prompt_color_seq}${end_prompt}%{${sgr_reset}${text_color_seq}%} " From 78a3b5949914987a71fbd7af2702b47d5089d1ba Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sun, 5 Jun 2022 14:58:59 -0400 Subject: [PATCH 08/13] Add debugging print. --- tcshrc.prompt.final | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index be4daca..67014cd 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -2,6 +2,10 @@ ### Final Prompt Setting ### ############################ +if( $?CSHENV_DEBUG ) then + echo "Setting up dynamic colour loading..." +endif + # Recompute cached sgr codes from any configuration updates if( ! $?curr_path_color ) then set curr_path_color=impossible @@ -69,6 +73,8 @@ if( "${curr_prompt_color}" != "${prompt_color}" ) then set prompt_color_seq="%{[`__build_sgr_code no-csi reset ${curr_prompt_color}`m%}" endif +if( $?CSHENV_DEBUG ) echo "Dynamic color loading processed..." + if( ${prompt_hcolor} != 0 ) then set last_color = ${reference_colors[${prompt_hcolor}]} From 2a3af31e7a1dd5fbc82c2dd8747e293503ae3d9f Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sun, 5 Jun 2022 15:03:03 -0400 Subject: [PATCH 09/13] Modernize the tty/line prompt. --- tcshrc.prompt.colors | 3 +-- tcshrc.prompt.defs | 3 ++- tcshrc.prompt.final | 10 +++++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tcshrc.prompt.colors b/tcshrc.prompt.colors index f5d4f65..634fde0 100644 --- a/tcshrc.prompt.colors +++ b/tcshrc.prompt.colors @@ -11,7 +11,7 @@ set host_color="ansi:12" set user_color="ansi:14" set at_color="${dim_cyan}" set path_color="ansi:10" -set line_color="${dim_red}" +set line_color="ansi:1" set prompt_color="reset" set depth_color="${dim_yellow}" @@ -19,7 +19,6 @@ set color_start="%{" set color_end="%}" set at_color_seq="${color_start}${at_color}${color_end}" -set line_color_seq="${color_start}${line_color}${color_end}" set depth_color_seq="${color_start}${depth_color}${color_end}" ########################### diff --git a/tcshrc.prompt.defs b/tcshrc.prompt.defs index e0085e0..6394b8c 100644 --- a/tcshrc.prompt.defs +++ b/tcshrc.prompt.defs @@ -125,7 +125,8 @@ endif set depth_prompt="${depth_color_seq}(${shlvl})" #we "convert" pts/$number entries to ttypK entries? -set line_prompt="${line_color_seq}`tty | sed -e 's;/dev/tty;;' -e 's;/dev/pts/;p/;' -e 's;/dev/;;' -e 's/not a tty/${unknown_tty}/'`" +set line_prompt="`tty | sed -e 's;/dev/tty;;' -e 's;/dev/pts/;p/;' -e 's;/dev/;;' -e 's/not a tty/${unknown_tty}/'`" +#set line_prompt="line" set user_prompt="%n" set host_prompt="${CSHENV_HOSTNAME}" set path_prompt="%c02" diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index 67014cd..7f21d96 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -7,6 +7,14 @@ if( $?CSHENV_DEBUG ) then endif # Recompute cached sgr codes from any configuration updates +if( ! $?curr_line_color ) then + set curr_line_color=impossible +endif +if( "${curr_line_color}" != "${line_color}" ) then + set curr_line_color="${line_color}" + set line_color_seq="%{[`__build_sgr_code no-csi reset ${curr_line_color}`m%}" +endif + if( ! $?curr_path_color ) then set curr_path_color=impossible endif @@ -232,7 +240,7 @@ if( ! $?CSHENV_DISABLE_PROMPT_SIGIL ) then set prompt_reference_view="${prompt_reference}" endif if( ! $?CSHENV_DISABLE_PROMPT_TTY ) then - set line_prompt_view="${line_prompt}" + set line_prompt_view="${line_color_seq}${line_prompt}" set line_spacer_view="%{${text_color_seq}%}\- " endif if( ! $?CSHENV_DISABLE_PROMPT_NESTING ) then From e9fe40ca91aac261f3965f0b3ef9ab2d5c1e2883 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sun, 5 Jun 2022 15:19:58 -0400 Subject: [PATCH 10/13] The aliases were not the way I decided to go... --- tcshrc.colors | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tcshrc.colors b/tcshrc.colors index 2aea2e3..6c68d49 100644 --- a/tcshrc.colors +++ b/tcshrc.colors @@ -72,13 +72,10 @@ set bright_white="$csi$ansi_bright;$ansi_white$ansi_color" # True colour support # ####################### -# The idea behind a true colour variable is that you run: `color_from_hex ff0077` and it expands to +# The idea behind a true colour variable is that you run: `__build_sgr_code ff0077` and it expands to # a proper colour sequence for a 24-bit color. The shell script which computes these will also attempt to # compute a rounded version of your color for use with 8-bit color and a weaker rounded form for use -# with 3 and 4 bit color. - -# You process true colour by evaluating `__make_color_sequence` on the environment variable. -alias __make_color_sequence ${CSHENV_DIR}/bin/__hex_to_ansi +# with 3 and 4 bit color. It does this based upon your terminal colour depth. set sgr_reset="[`__build_sgr_code no-csi reset`m" From 00338131e57667e23cfdae069cf758ca82157ebe Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sun, 5 Jun 2022 15:37:08 -0400 Subject: [PATCH 11/13] Colour for nesting depth prompt is now modernized --- tcshrc.prompt.colors | 3 +-- tcshrc.prompt.defs | 2 +- tcshrc.prompt.final | 10 +++++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tcshrc.prompt.colors b/tcshrc.prompt.colors index 634fde0..f0b2879 100644 --- a/tcshrc.prompt.colors +++ b/tcshrc.prompt.colors @@ -13,13 +13,12 @@ set at_color="${dim_cyan}" set path_color="ansi:10" set line_color="ansi:1" set prompt_color="reset" -set depth_color="${dim_yellow}" +set depth_color="ansi:3" set color_start="%{" set color_end="%}" set at_color_seq="${color_start}${at_color}${color_end}" -set depth_color_seq="${color_start}${depth_color}${color_end}" ########################### # vim:filetype=tcsh diff --git a/tcshrc.prompt.defs b/tcshrc.prompt.defs index 6394b8c..28b9905 100644 --- a/tcshrc.prompt.defs +++ b/tcshrc.prompt.defs @@ -122,7 +122,7 @@ if( $?CSHENV_DEBUG ) then endif -set depth_prompt="${depth_color_seq}(${shlvl})" +set depth_prompt="(${shlvl})" #we "convert" pts/$number entries to ttypK entries? set line_prompt="`tty | sed -e 's;/dev/tty;;' -e 's;/dev/pts/;p/;' -e 's;/dev/;;' -e 's/not a tty/${unknown_tty}/'`" diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index 7f21d96..5366ee2 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -7,6 +7,14 @@ if( $?CSHENV_DEBUG ) then endif # Recompute cached sgr codes from any configuration updates +if( ! $?curr_depth_color ) then + set curr_depth_color=impossible +endif +if( "${curr_depth_color}" != "${depth_color}" ) then + set curr_depth_color="${depth_color}" + set depth_color_seq="%{[`__build_sgr_code no-csi reset ${curr_depth_color}`m%}" +endif + if( ! $?curr_line_color ) then set curr_line_color=impossible endif @@ -248,7 +256,7 @@ if( ! $?CSHENV_DISABLE_PROMPT_NESTING ) then if( ! $?CSHENV_DISABLE_PROMPT_TTY ) then set depth_prompt_spacing=" " endif - set depth_prompt_view="${depth_prompt_spacing}${depth_prompt}" + set depth_prompt_view="${depth_color_seq}${depth_prompt_spacing}${depth_prompt}" if( $?CSHENV_HIDE_SHELL_LEVEL_AT_ONE ) then if( ${shlvl} == 1 ) then set depth_prompt_view="" From ba73d1b7982a4e9f5d9bdfa3f2df897620c7c414 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sun, 5 Jun 2022 23:10:11 -0400 Subject: [PATCH 12/13] Added support for underline colour in sgr gen. --- bin/__build_sgr_code | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/__build_sgr_code b/bin/__build_sgr_code index a963409..560c27c 100755 --- a/bin/__build_sgr_code +++ b/bin/__build_sgr_code @@ -119,10 +119,14 @@ function render_color() command_color=30 if (( ${use_3_bit} )) then - basecolor=$(( ${command_color} )) + # Underline colours need 8-bit or more + if (( ${background} > 1 )) ; then return; fi + basecolor=$(( ${command_color} + ${background}*10)) next="$(( ${basecolor} + ${legacy_3_bit} ))" elif (( ${use_4_bit} )) then + # Underline colours need 8-bit or more + if (( ${background} > 1 )) ; then return; fi command_color=$(( ${command_color} + ${intensity_1_bit} * 60 )) basecolor=$(( ${command_color} + ${background}*10 )) next="$(( ${basecolor} + ${legacy_3_bit} ))" @@ -381,8 +385,14 @@ do bg:[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]) make_color 1 rgb_color ${1:3} ;; bg:[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]) make_color 1 rgb_color ${1:3} ;; + ul:ext:*) make_color 2 ext_color ${1:7} ;; + # 12-bit color also supported + ul:[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]) make_color 2 rgb_color ${1:3} ;; + ul:[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]) make_color 2 rgb_color ${1:3} ;; + fg:*) make_color 0 named_color ${1:3} ;; bg:*) make_color 1 named_color ${1:3} ;; + ul:*) make_color 2 named_color ${1:3} ;; *) make_color 0 named_color $1 ;; esac if [[ ! -z ${output} ]] From e1e030f6123c645c3ebd720979272ad6c9bbb6dd Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sun, 5 Jun 2022 23:15:18 -0400 Subject: [PATCH 13/13] Percent, branch, and @ all had to be done at once. Because they were kinda intertwined in the colours I chose. --- tcshrc.prompt.colors | 12 +++++++----- tcshrc.prompt.final | 29 +++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/tcshrc.prompt.colors b/tcshrc.prompt.colors index f0b2879..0b34b25 100644 --- a/tcshrc.prompt.colors +++ b/tcshrc.prompt.colors @@ -2,6 +2,8 @@ ### PROMPT COLOURS ### ###################### +# Note - It is not recommended to edit this. These are the default values. +# Edit your `.user` or other config files to override these. set date_color="ansi:5" set time_color="ansi:13" @@ -9,16 +11,16 @@ set text_color="reset" set brace_color="ansi:11" set host_color="ansi:12" set user_color="ansi:14" -set at_color="${dim_cyan}" +set at_color="ansi:6" set path_color="ansi:10" set line_color="ansi:1" set prompt_color="reset" 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 color_start="%{" -set color_end="%}" - -set at_color_seq="${color_start}${at_color}${color_end}" +alias load_default_prompt_colors source ${CSHENV_DIR}/tcshrc.prompt.colors ########################### # vim:filetype=tcsh diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index 5366ee2..db9c1e6 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -7,6 +7,31 @@ if( $?CSHENV_DEBUG ) then endif # Recompute cached sgr codes from any configuration updates +if( ! $?curr_branch_color ) then + set curr_branch_color=impossible +endif +if( "${curr_branch_color}" != "${branch_color}" ) then + set curr_branch_color="${branch_color}" + set branch_color_seq="%{[`__build_sgr_code no-csi reset ${curr_branch_color}`m" +endif + + +if( ! $?curr_percent_color ) then + set curr_percent_color=impossible +endif +if( "${curr_percent_color}" != "${percent_color}" ) then + set curr_percent_color="${percent_color}" + set percent_color_seq="[`__build_sgr_code no-csi reset ${curr_percent_color}`m" +endif + +if( ! $?curr_at_color ) then + set curr_at_color=impossible +endif +if( "${curr_at_color}" != "${at_color}" ) then + set curr_at_color="${at_color}" + set at_color_seq="%{[`__build_sgr_code no-csi reset ${curr_at_color}`m%}" +endif + if( ! $?curr_depth_color ) then set curr_depth_color=impossible endif @@ -202,7 +227,7 @@ if( $?CSHENV_SHOW_BATTERY_LEVEL ) then #set battery_prompt="%{${battery_color}%}%{${battery_level}${at_color}\%%}%{${dim}%} " set battery_prefix="%{${csi}m${csi}28D%}" - set battery_prompt="%{${csi}38;2;128;128;255;3mBattery Level:${dim} ${battery_color}${battery_level}${at_color}\%${dim} %}" + set battery_prompt="%{${csi}38;2;128;128;255;3mBattery Level:${sgr_reset} ${battery_color}${battery_level}${percent_color_seq}%${sgr_reset} %}" else set battery_prefix="" set battery_prompt="" @@ -226,7 +251,7 @@ if( 0 == ${__res} ) then # I could always fallback to this one... (keep padded spaces... for alignment) set branch_symbol=`printf '\u2387\ \ \ '` - set git_prompt="%{${csi}0;60m%}(${branch_symbol} %{${csi}3;4;38;2;255;192;192;58;2;255;255;255;68;2;255;255;255m%}${git_branch}%{${csi}m%}) " + set git_prompt="%{${sgr_reset}%}(${branch_symbol} %{${branch_color_seq}%}${git_branch}%{${sgr_reset}%}) " #set git_prompt="%{${csi}10D${csi}2D(xyz${git_branch})${csi}m%%}" #set git_prompt="%{${csi}0;35m${csi}50D${git_branch} %}" endif