From 910f194c4e4f45aef6b9adee5eb668d66f470110 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Fri, 3 Jun 2022 20:12:55 -0400 Subject: [PATCH 01/35] Use a more portable branch symbol. (I need a way to auto-detect the powerline one and use it when that is present.) --- tcshrc.prompt.final | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index de1fd53..a43bc8b 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -132,7 +132,7 @@ if( 0 == ${__res} ) then # If the font doesn't support the special branch symbol... set branch_symbol=`printf "\uE0A0"` # I could always fallback to this one... (keep padded spaces... for alignment) - #set branch_symbol=`printf "\u2387 "` + 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="%{${csi}10D${csi}2D(xyz${git_branch})${csi}m%%}" From 328c1c13e326766a70e61a5639446e3e9f27d8c6 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Fri, 3 Jun 2022 21:31:26 -0400 Subject: [PATCH 02/35] Fine grained control over prompt elements. Use `CSHENV_DISABLE_PROMPT_` env vars to control these. --- tcshrc.prompt.defs | 7 +----- tcshrc.prompt.final | 53 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/tcshrc.prompt.defs b/tcshrc.prompt.defs index 52428e5..3e01620 100644 --- a/tcshrc.prompt.defs +++ b/tcshrc.prompt.defs @@ -122,12 +122,7 @@ if( $?CSHENV_DEBUG ) then endif -set depth_prompt=" ${depth_color_seq}(${shlvl})${text_color_seq}\- " -if( $?CSHENV_HIDE_SHELL_LEVEL_AT_ONE ) then - if( $shlvl == 1 ) then - set depth_prompt="${text_color_seq}\- " - endif -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}/'`" diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index a43bc8b..3043893 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -142,7 +142,58 @@ else 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}${brace_color_seq}\[${prompt_reference}${line_prompt}${depth_prompt}${user_prompt}${at_color_seq}@${host_prompt}${text_color_seq}\: ${git_prompt}${path_prompt}${brace_color_seq}\]${end_prompt}" +set prompt_reference_view="" +set line_prompt_view="" +set depth_prompt_view="" +set user_prompt_view +set at_view="" +set host_prompt_view="" +set git_prompt_view="" +set path_prompt_view="" +set line_spacer_view="" + +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_spacer_view="${text_color_seq}\- " +endif +if( ! $?CSHENV_DISABLE_PROMPT_NESTING ) then + set depth_prompt_spacing="" + if( ! $?CSHENV_DISABLE_PROMPT_TTY ) then + set depth_prompt_spacing=" " + endif + set depth_prompt_view="${depth_prompt_spacing}${depth_prompt}" + if( $?CSHENV_HIDE_SHELL_LEVEL_AT_ONE ) then + if( ${shlvl} == 1 ) then + set depth_prompt_view="" + endif + endif +endif +if( ! $?CSHENV_DISABLE_PROMPT_USER ) then + set user_prompt_view="${user_prompt}" + if( ! $?CSHENV_DISABLE_PROMPT_HOST ) then + set at_view="${at_color_seq}@" + endif +endif +if( ! $?CSHENV_DISABLE_PROMPT_HOST ) then + set host_prompt_tail=": " + 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}" +endif +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}" +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}" + + if( ! ${?cshenv_user_prompt_override} ) then set prompt="$prompt_cool" From 856fd35085c201f54f86c881bef571c4953c0dfe Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 4 Jun 2022 01:22:12 -0400 Subject: [PATCH 03/35] This sets me up to do more adaptive colours with the prompt. Colours now can use 24-bit colour sequences. A script drives the generation of SGR codes... Now I just have to integrate this into `tcshrc.prompt.final`, for dynamic updating. --- bin/__hex_to_ansi | 214 ++++++++++++++++++++++++++++++++++++++++++++++ tcshrc.colors | 25 ++++++ 2 files changed, 239 insertions(+) create mode 100755 bin/__hex_to_ansi diff --git a/bin/__hex_to_ansi b/bin/__hex_to_ansi new file mode 100755 index 0000000..f485483 --- /dev/null +++ b/bin/__hex_to_ansi @@ -0,0 +1,214 @@ +#!/usr/bin/env bash + +# This script will take an HTML compatible hex colour string and turn it into +# a terminal sequence for true colour and other formats which best approximate +# its colour value. + +debug=0 + +if [ ${1} == "fg" ] +then + background=0 +elif [ ${1} == "bg" ] +then + background=1 +else + exit -1 +fi + +shift 1 + +use_8_bit=0 +use_4_bit=0 +use_3_bit=0 + +if [ ${1:0:5} == "ansi:" ] +then + selection=${1:5} + if (( ${selection} > 15 )) + then + exit -1 + elif (( ${selection} >= 8 )) + then + use_4_bit=1 + intensity_1_bit=1 + legacy_3_bit=$(( ${selection} - 8 )) + else + use_3_bit=1 + intensity_1_bit=0 + legacy_3_bit=$(( ${selection} )) + fi +elif [ ${1:0:4} == "ext:" ] +then + use_8_bit=1 + selection=${1:4} + if (( ${selection} > 255 )) + then + exit -1 + else + ext_8_bit=${selection} + fi +else # Parse the hex and do the thing... + + # First split off the red, green, and blue components... + red_hex=${1:0:2} + green_hex=${1:2:2} + blue_hex=${1:4:2} + + # Convert to decimal... + red_dec=$((16#${red_hex})) + green_dec=$((16#${green_hex})) + blue_dec=$((16#${blue_hex})) + + if (( ${debug} != 0 )) + then + echo "Red: $red_dec" + echo "Green: $green_dec" + echo "Blue: $blue_dec" + fi + + # Now compute the rest of the stuff... + + # We probably don't have to compute all the unused color states. We only have to compute + # the color state we're signed up for by CSHENV_TERMINAL_COLORS... but whatever... + + # We round up by 128 points of colour, so that if we're above a certain intensity, we get the top + # bit set. + + red_1_bit=$(( ( ( ${red_dec} + 128 ) >> 8 ) & 1 )) + green_1_bit=$(( ( ( ${green_dec} + 128 ) >> 8 ) & 1 )) + blue_1_bit=$(( ( ( ${blue_dec} + 128 ) >> 8 ) & 1 )) + intensity_1_bit=0 + + + # If we can support an intensity bit, we'll turn that on too... + # But we're going to stop using bold to set the colour "intense" + # We'll use the 9x and 10x forms... + if (( ${red_dec} >= 192 || ${green_dec} >= 192 || ${blue_dec} >= 192 )) + then + intensity_1_bit=1 + fi + + if (( ${debug} != 0 )) + then + echo "Red bit: " $red_1_bit + echo "Green bit: " $green_1_bit + echo "Blue bit: " $blue_1_bit + echo "Intensity bit: " $intensity_1_bit + fi + + # This lets us combine them for a legacy colour value in the legacy colour space... + + legacy_3_bit=$(( ( ${blue_1_bit} << 2 ) + ( ${green_1_bit} << 1 ) + ( ${red_1_bit} ) )) + + if (( ${debug} != 0 )) + then + echo "Legacy colour: " ${legacy_3_bit} " Intensity: " ${intensity_1_bit} + fi + + # Now compute an extended colour cube placement (216 colours): + + red_ext_val=$(( ${red_dec} * 6 / 256 )) + green_ext_val=$(( ${green_dec} * 6 / 256 )) + blue_ext_val=$(( ${blue_dec} * 6 / 256 )) + + if (( ${debug} != 0 )) + then + echo "Red ext: " ${red_ext_val} + echo "Green ext: " ${green_ext_val} + echo "Blue ext: " ${blue_ext_val} + fi + + ext_8_bit=$(( 16 + 36 * ${red_ext_val} + 6 * ${green_ext_val} + ${blue_ext_val} )) + + if (( ${debug} )) + then + echo "Computed 216 color cube: " ${ext_8_bit} + fi + + # Check for precise greyscale, which would replace the above: + # (Note that precise greyscale is implied by a user explicitly making ALL of RGB the + # same value, thus demanding greyscale, rather than a subtle tinting...) + + if (( ${red_dec} == ${green_dec} && ${green_dec} == ${blue_dec} )) + then + ext_8_bit=$(( 232 + ${red_dec} * 24 / 256 )) + fi + + if (( ${debug} )) + then + echo "Computed 256 color choice, after applying greyscale scan: " ${ext_8_bit} + fi + + # Check for SPECIFIC white and black and grey: + # The half-saturation, no saturation, and full saturation values are mapped + # to specific points in the legacy set. (This may be ill-advised as a manually + # built reverse video terminal setting through colour mapping may make it so that + # we wind up in la-la land. Perhaps the better way is to find the head and tail + # points in the 6x6x6 colour cube.) + # + # TODO: Only map the head and tail of the colour cube. + if (( ${red_dec} == ${green_dec} && ${green_dec} == ${blue_dec} )) + then + if (( ${red_dec} == 0 )) + then + ext_8_bit=0 + elif (( ${red_dec} == 255 )) + then + ext_8_bit=15 + elif (( ${red_dec} == 128 )) + then + ext_8_bit=8 + elif (( ${red_dec} == 192 )) + then + ext_8_bit=7 + fi + fi + + if (( ${debug} )) + then + echo "Computed 256 color choice, after applying white and black scan: " ${ext_8_bit} + fi + + # We do NOT check for the base colours precisely. Since those 16 can be custom mapped by your terminal emulator, you just pass `ansi:0` thru + # `ansi:15` to select them by ID. Or use `ext:0` thru `ext:255` to select a specific extended colour. Otherwise, we now generate the true-colour + # result: +fi + +# Must only be set if terminal colors are reduced... +if [[ -v CSHENV_TERMINAL_COLORS ]] +then + if (( ${CSHENV_TERMINAL_COLORS} == 256 )) + then + use_8_bit=1 + elif (( ${CSHENV_TERMINAL_COLORS} == 16 )) + then + use_4_bit=1 + elif (( ${CSHENV_TERMINAL_COLORS} == 8 )) + then + use_3_bit=1 + else + exit -1 + fi +fi + +command_color=30 +if (( ${use_3_bit} )) +then + basecolor=$(( ${command_color} )) + printf $(( ${basecolor} + ${legacy_3_bit} )) +elif (( ${use_4_bit} )) +then + command_color=$(( ${command_color} + ${intensity_1_bit} * 60 )) + basecolor=$(( ${command_color} + ${background}*10 )) + printf $(( ${basecolor} + ${legacy_3_bit} )) +elif (( ${use_8_bit} )) +then + basecolor=$(( 8 + ${command_color} + ${background}*10 )) + printf "${basecolor};5;${ext_8_bit}" +else + basecolor=$(( 8 + ${command_color} + ${background}*10 )) + printf "${basecolor};2;${red_dec};${green_dec};${blue_dec}" +fi + +exit 0 diff --git a/tcshrc.colors b/tcshrc.colors index 6aba697..79a890b 100644 --- a/tcshrc.colors +++ b/tcshrc.colors @@ -4,6 +4,7 @@ set csi='[' +# Legacy 3-bit ANSI Forms: set ansi_bright='1' set ansi_dim='0' set ansi_color='m' @@ -34,6 +35,10 @@ set magenta="$csi$ansi_magenta$ansi_color" set cyan="$csi$ansi_cyan$ansi_color" set white="$csi$ansi_white$ansi_color" +# Bright and Dim rely upon the console's setting of colour intensity paired +# to boldness intensity. For better colour choices, it's better to use +# extended colours or true colours. + set dim_black="$csi$ansi_dim;$ansi_black$ansi_color" @@ -55,6 +60,26 @@ set bright_magenta="$csi$ansi_bright;$ansi_magenta$ansi_color" set bright_cyan="$csi$ansi_bright;$ansi_cyan$ansi_color" set bright_white="$csi$ansi_bright;$ansi_white$ansi_color" +# Also somewhat legacy are the extended colours... so I'm not implementing them. +# Instead, I'll use my script which does math on the 6 char hex string you use in +# colors... + +################################# +# Extended 8-bit colour Support # +################################# + +####################### +# True colour support # +####################### + +# The idea behind a true colour variable is that you run: `color_from_hex 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 + ########################### # vim:filetype=tcsh From e34caae816d9dfe16f43ced884d77a4274e59341 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 4 Jun 2022 03:32:56 -0400 Subject: [PATCH 04/35] Add support for other SGR tokens to the ansi code builder. --- bin/__hex_to_ansi | 81 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 65 insertions(+), 16 deletions(-) diff --git a/bin/__hex_to_ansi b/bin/__hex_to_ansi index f485483..3332d50 100755 --- a/bin/__hex_to_ansi +++ b/bin/__hex_to_ansi @@ -3,6 +3,13 @@ # This script will take an HTML compatible hex colour string and turn it into # a terminal sequence for true colour and other formats which best approximate # its colour value. +# +# After that, we can map a few other special named symbols. The idea is to +# permit shell variables such as `aaffcc bold italic` to indicate what you +# want a format to look like. +# +# TODO: Update the script to allow for `bg:ff00ff` style descriptions, instead +# of positional. debug=0 @@ -22,7 +29,14 @@ use_8_bit=0 use_4_bit=0 use_3_bit=0 -if [ ${1:0:5} == "ansi:" ] +skip_color=0 +if [ $1 == "none" ] +then + skip_color=1 +elif [ $1 == "reset" ] +then + output=1 +elif [ ${1:0:5} == "ansi:" ] then selection=${1:5} if (( ${selection} > 15 )) @@ -192,23 +206,58 @@ then fi fi -command_color=30 -if (( ${use_3_bit} )) +output="" + +if (( ! ${skip_color} )) then - basecolor=$(( ${command_color} )) - printf $(( ${basecolor} + ${legacy_3_bit} )) -elif (( ${use_4_bit} )) + command_color=30 + if (( ${use_3_bit} )) + then + basecolor=$(( ${command_color} )) + output="$(( ${basecolor} + ${legacy_3_bit} ))" + elif (( ${use_4_bit} )) + then + command_color=$(( ${command_color} + ${intensity_1_bit} * 60 )) + basecolor=$(( ${command_color} + ${background}*10 )) + output="$(( ${basecolor} + ${legacy_3_bit} ))" + elif (( ${use_8_bit} )) + then + basecolor=$(( 8 + ${command_color} + ${background}*10 )) + output="${basecolor};5;${ext_8_bit}" + else + basecolor=$(( 8 + ${command_color} + ${background}*10 )) + output="${basecolor};2;${red_dec};${green_dec};${blue_dec}" + fi +elif (( ${reset_sgr} )) then - command_color=$(( ${command_color} + ${intensity_1_bit} * 60 )) - basecolor=$(( ${command_color} + ${background}*10 )) - printf $(( ${basecolor} + ${legacy_3_bit} )) -elif (( ${use_8_bit} )) -then - basecolor=$(( 8 + ${command_color} + ${background}*10 )) - printf "${basecolor};5;${ext_8_bit}" -else - basecolor=$(( 8 + ${command_color} + ${background}*10 )) - printf "${basecolor};2;${red_dec};${green_dec};${blue_dec}" + output="0" fi +shift 1 +while [[ ! -z $1 ]] +do + case $1 in + bold) next=1 ;; + dim) next=2 ;; + italic) next=3 ;; + underline|under) next=4 ;; + blink) next=5 ;; + fastblink) next=6 ;; + reverse) next=7 ;; + hide|conceal) next=8 ;; + strike|strikethrough|strikethru) next=9 ;; + doubleunder) next=21 ;; + reveal) next=28 ;; + *) exit -1 ;; + esac + if [[ ! -z ${output} ]] + then + output="${output};" + fi + output="${output}${next}" + shift 1 +done + +printf ${output} + exit 0 From f5ced0e3882d22beb255829e63ecc9364e351d89 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 4 Jun 2022 08:27:21 -0400 Subject: [PATCH 05/35] Now `__build_sgr_code` supports a simple language This makes it easy in configs to build control codes for colour, etc. --- bin/{__hex_to_ansi => __build_sgr_code} | 167 ++++++++++++++---------- 1 file changed, 95 insertions(+), 72 deletions(-) rename bin/{__hex_to_ansi => __build_sgr_code} (74%) diff --git a/bin/__hex_to_ansi b/bin/__build_sgr_code similarity index 74% rename from bin/__hex_to_ansi rename to bin/__build_sgr_code index 3332d50..5141d79 100755 --- a/bin/__hex_to_ansi +++ b/bin/__build_sgr_code @@ -13,57 +13,92 @@ debug=0 -if [ ${1} == "fg" ] +nocsi=0 +if [[ $1 == "no-csi" ]] then - background=0 -elif [ ${1} == "bg" ] -then - background=1 -else - exit -1 + nocsi=1 + shift 1 fi -shift 1 +function setup_color_depth() +{ + use_8_bit=0 + use_4_bit=0 + use_3_bit=0 -use_8_bit=0 -use_4_bit=0 -use_3_bit=0 + # Must only be set if terminal colors are reduced... + if [[ -v CSHENV_TERMINAL_COLORS ]] + then + if (( ${CSHENV_TERMINAL_COLORS} == 256 )) + then + use_8_bit=1 + elif (( ${CSHENV_TERMINAL_COLORS} == 16 )) + then + use_4_bit=1 + elif (( ${CSHENV_TERMINAL_COLORS} == 8 )) + then + use_3_bit=1 + else + exit -1 + fi + fi +} -skip_color=0 -if [ $1 == "none" ] -then - skip_color=1 -elif [ $1 == "reset" ] -then - output=1 -elif [ ${1:0:5} == "ansi:" ] -then - selection=${1:5} - if (( ${selection} > 15 )) +function render_color() +{ + command_color=30 + if (( ${use_3_bit} )) + then + basecolor=$(( ${command_color} )) + next="$(( ${basecolor} + ${legacy_3_bit} ))" + elif (( ${use_4_bit} )) + then + command_color=$(( ${command_color} + ${intensity_1_bit} * 60 )) + basecolor=$(( ${command_color} + ${background}*10 )) + next="$(( ${basecolor} + ${legacy_3_bit} ))" + elif (( ${use_8_bit} )) + then + basecolor=$(( 8 + ${command_color} + ${background}*10 )) + next="${basecolor};5;${ext_8_bit}" + else + basecolor=$(( 8 + ${command_color} + ${background}*10 )) + next="${basecolor};2;${red_dec};${green_dec};${blue_dec}" + fi +} + + + +function ansi_color() +{ + if (( ${1} > 15 )) then exit -1 - elif (( ${selection} >= 8 )) + elif (( ${1} >= 8 )) then use_4_bit=1 intensity_1_bit=1 - legacy_3_bit=$(( ${selection} - 8 )) + legacy_3_bit=$(( ${1} - 8 )) else use_3_bit=1 intensity_1_bit=0 - legacy_3_bit=$(( ${selection} )) + legacy_3_bit=$(( ${1} )) fi -elif [ ${1:0:4} == "ext:" ] -then +} + +function ext_color() +{ use_8_bit=1 selection=${1:4} - if (( ${selection} > 255 )) + if (( ${1} > 255 )) then exit -1 else - ext_8_bit=${selection} + ext_8_bit=${1} fi -else # Parse the hex and do the thing... +} +function rgb_color() +{ # First split off the red, green, and blue components... red_hex=${1:0:2} green_hex=${1:2:2} @@ -187,56 +222,26 @@ else # Parse the hex and do the thing... # We do NOT check for the base colours precisely. Since those 16 can be custom mapped by your terminal emulator, you just pass `ansi:0` thru # `ansi:15` to select them by ID. Or use `ext:0` thru `ext:255` to select a specific extended colour. Otherwise, we now generate the true-colour # result: -fi +} -# Must only be set if terminal colors are reduced... -if [[ -v CSHENV_TERMINAL_COLORS ]] -then - if (( ${CSHENV_TERMINAL_COLORS} == 256 )) - then - use_8_bit=1 - elif (( ${CSHENV_TERMINAL_COLORS} == 16 )) - then - use_4_bit=1 - elif (( ${CSHENV_TERMINAL_COLORS} == 8 )) - then - use_3_bit=1 - else - exit -1 - fi -fi +function make_color() +{ + setup_color_depth + background=$1 # $1 is the background bit + $2 $3 # $2 is the color function + render_color +} output="" - -if (( ! ${skip_color} )) +if (( ! ${nocsi} )) then - command_color=30 - if (( ${use_3_bit} )) - then - basecolor=$(( ${command_color} )) - output="$(( ${basecolor} + ${legacy_3_bit} ))" - elif (( ${use_4_bit} )) - then - command_color=$(( ${command_color} + ${intensity_1_bit} * 60 )) - basecolor=$(( ${command_color} + ${background}*10 )) - output="$(( ${basecolor} + ${legacy_3_bit} ))" - elif (( ${use_8_bit} )) - then - basecolor=$(( 8 + ${command_color} + ${background}*10 )) - output="${basecolor};5;${ext_8_bit}" - else - basecolor=$(( 8 + ${command_color} + ${background}*10 )) - output="${basecolor};2;${red_dec};${green_dec};${blue_dec}" - fi -elif (( ${reset_sgr} )) -then - output="0" + output="[" fi -shift 1 while [[ ! -z $1 ]] do case $1 in + reset) next=0 ;; bold) next=1 ;; dim) next=2 ;; italic) next=3 ;; @@ -248,7 +253,20 @@ do strike|strikethrough|strikethru) next=9 ;; doubleunder) next=21 ;; reveal) next=28 ;; - *) exit -1 ;; + + ansi:*) make_color 0 ansi_color ${1:5} ;; + ext:*) make_color 0 ext_color ${1:4} ;; + [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 0 rgb_color $1 ;; + + fg:ansi:*) make_color 0 ansi_color ${1:8} ;; + fg:ext:*) make_color 0 ext_color ${1:7} ;; + fg:[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 0 rgb_color ${1:3} ;; + + bg:ansi:*) make_color 1 ansi_color ${1:8} ;; + bg:ext:*) make_color 1 ext_color ${1:7} ;; + 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} ;; + + *) echo "ERROR!" 1>&2 ; exit -1 ;; esac if [[ ! -z ${output} ]] then @@ -258,6 +276,11 @@ do shift 1 done +if (( ! ${nocsi} )) +then + output="${output}m" +fi + printf ${output} exit 0 From 5d0e0d37411d0a8472937228b2e25d29f81ccca0 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 4 Jun 2022 08:55:33 -0400 Subject: [PATCH 06/35] Add named colour support to SGI builder. I'd like to add support for a named color table which can be scanned in... --- bin/__build_sgr_code | 62 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/bin/__build_sgr_code b/bin/__build_sgr_code index 5141d79..04b26f9 100755 --- a/bin/__build_sgr_code +++ b/bin/__build_sgr_code @@ -13,6 +13,27 @@ debug=0 +# This is the named color map. Just add new entries and they'll be supported... + +declare -A map +map[white]="FFFFFF" +map[silver]="C0C0C0" +map[gray]="808080" +map[black]="000000" +map[red]="FF0000" +map[maroon]="800000" +map[yellow]="FFFF00" +map[olive]="808000" +map[lime]="00FF00" +map[green]="008000" +map[aqua]="00FFFF" +map[teal]="008080" +map[blue]="0000FF" +map[navy]="000080" +map[fuchsia]="FF00FF" +map[purple]="800080" +map[brown]="aa5500" # Based upon wikipedia's article on ANSI. This is the approximation of VGA brown. + nocsi=0 if [[ $1 == "no-csi" ]] then @@ -232,15 +253,35 @@ function make_color() render_color } +function dump_colors() +{ + for key in ${!map[@]} + do + echo $key - ${map[${key}]} + done + + exit 0 +} + +function named_color() +{ + name=${1,,} + if [[ ! -v map[$name] ]] + then + echo "ERROR!" 1>&2 ; exit -1 + fi + + mapped=${map[$name]} + rgb_color ${mapped} +} + output="" -if (( ! ${nocsi} )) -then - output="[" -fi while [[ ! -z $1 ]] do case $1 in + dump-colors) dump_colors ;; + reset) next=0 ;; bold) next=1 ;; dim) next=2 ;; @@ -266,7 +307,9 @@ do bg:ext:*) make_color 1 ext_color ${1:7} ;; 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} ;; - *) echo "ERROR!" 1>&2 ; exit -1 ;; + fg:*) make_color 0 named_color ${1:3} ;; + bg:*) make_color 1 named_color ${1:3} ;; + *) make_color 0 named_color $1 ;; esac if [[ ! -z ${output} ]] then @@ -276,11 +319,14 @@ do shift 1 done -if (( ! ${nocsi} )) +if [[ ! -z ${output} ]] && (( ! ${nocsi} )) then - output="${output}m" + output="[${output}m" +fi +if [[ ! -z ${output} ]] +then + printf ${output} fi -printf ${output} exit 0 From 7007770cb5bfcac4208bb77eb229ceb986f9f32f Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 4 Jun 2022 09:10:51 -0400 Subject: [PATCH 07/35] Add 12-bit color support. --- bin/__build_sgr_code | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/bin/__build_sgr_code b/bin/__build_sgr_code index 04b26f9..eba9f6f 100755 --- a/bin/__build_sgr_code +++ b/bin/__build_sgr_code @@ -120,10 +120,14 @@ function ext_color() function rgb_color() { + color=$1 + case $1 in + [0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]) color=${1:0:1}${1:0:1}${1:1:1}${1:1:1}${1:2:1}${1:2:1} ;; + esac # First split off the red, green, and blue components... - red_hex=${1:0:2} - green_hex=${1:2:2} - blue_hex=${1:4:2} + red_hex=${color:0:2} + green_hex=${color:2:2} + blue_hex=${color:4:2} # Convert to decimal... red_dec=$((16#${red_hex})) @@ -297,14 +301,20 @@ do ansi:*) make_color 0 ansi_color ${1:5} ;; ext:*) make_color 0 ext_color ${1:4} ;; + # 12-bit color also supported + [0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]) make_color 0 rgb_color $1 ;; [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 0 rgb_color $1 ;; fg:ansi:*) make_color 0 ansi_color ${1:8} ;; fg:ext:*) make_color 0 ext_color ${1:7} ;; + # 12-bit color also supported + fg:[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]) make_color 0 rgb_color ${1:3} ;; fg:[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 0 rgb_color ${1:3} ;; bg:ansi:*) make_color 1 ansi_color ${1:8} ;; bg:ext:*) make_color 1 ext_color ${1:7} ;; + # 12-bit color also supported + 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} ;; fg:*) make_color 0 named_color ${1:3} ;; From 89446b9e4b5fabbda7f6fd84d8a67e53526d32f6 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 4 Jun 2022 09:16:25 -0400 Subject: [PATCH 08/35] Add the whole EGA/VGA selection to the name table. --- bin/__build_sgr_code | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/bin/__build_sgr_code b/bin/__build_sgr_code index eba9f6f..f3690a6 100755 --- a/bin/__build_sgr_code +++ b/bin/__build_sgr_code @@ -19,6 +19,7 @@ declare -A map map[white]="FFFFFF" map[silver]="C0C0C0" map[gray]="808080" +map[grey]="808080" map[black]="000000" map[red]="FF0000" map[maroon]="800000" @@ -32,7 +33,34 @@ map[blue]="0000FF" map[navy]="000080" map[fuchsia]="FF00FF" map[purple]="800080" -map[brown]="aa5500" # Based upon wikipedia's article on ANSI. This is the approximation of VGA brown. + +# Some VGA color names can be promoted: +map[brown]="aa5500" +map[cyan]="00aaaa" + + +# The VGA names can be prefixed with "vga-" to explicitly avoid the collisions with HTML names, above... +# Based upon wikipedia's article on ANSI. See the table on that page for details. +map[vga-black]="000000" +map[vga-red]="aa0000" +map[vga-green]="00aa00" +map[vga-brown]="aa5500" +map[vga-yellow]="aa5500" +map[vga-blue]="0000aa" +map[vga-magenta]="aa00aa" +map[vga-cyan]="aaaa00" +map[vga-white]="aaaaaa" + +map[vga-brightblack]="555555" +map[vga-grey]="555555" +map[vga-gray]="555555" +map[vga-brightred]="ff5555" +map[vga-brightgreen]="55ff55" +map[vga-brightyellow]="ffff55" +map[vga-brightblue]="5555ff" +map[vga-brightmagenta]="ff55ff" +map[vga-brightcyan]="55ffff" +map[vga-brightwhite]="ffffff" nocsi=0 if [[ $1 == "no-csi" ]] From 5bbd039f7c9d7db22ad40b664c8247953d8b802d Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 4 Jun 2022 09:29:38 -0400 Subject: [PATCH 09/35] Make color dump pretty. --- bin/__build_sgr_code | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/__build_sgr_code b/bin/__build_sgr_code index f3690a6..16cc572 100755 --- a/bin/__build_sgr_code +++ b/bin/__build_sgr_code @@ -289,7 +289,7 @@ function dump_colors() { for key in ${!map[@]} do - echo $key - ${map[${key}]} + printf "%-24s${map[${key}]} |`$0 reset reverse fg:${key}`sample`$0 reset`|\n" ${key} done exit 0 From 1c32e0aa8c29fecb21dde2f4a775209e41423811 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 4 Jun 2022 09:29:55 -0400 Subject: [PATCH 10/35] Move color dump to earlier in sgr builder. --- bin/__build_sgr_code | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bin/__build_sgr_code b/bin/__build_sgr_code index 16cc572..f8ffe17 100755 --- a/bin/__build_sgr_code +++ b/bin/__build_sgr_code @@ -69,6 +69,16 @@ then shift 1 fi +function dump_colors() +{ + for key in ${!map[@]} + do + printf "%-24s${map[${key}]} |`$0 reset reverse fg:${key}`sample`$0 reset`|\n" ${key} + done + + exit 0 +} + function setup_color_depth() { use_8_bit=0 @@ -285,16 +295,6 @@ function make_color() render_color } -function dump_colors() -{ - for key in ${!map[@]} - do - printf "%-24s${map[${key}]} |`$0 reset reverse fg:${key}`sample`$0 reset`|\n" ${key} - done - - exit 0 -} - function named_color() { name=${1,,} From 216807a4cdf61a6964a29692edc1dbf468ef7298 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 4 Jun 2022 09:30:49 -0400 Subject: [PATCH 11/35] Did the todo! --- bin/__build_sgr_code | 3 --- 1 file changed, 3 deletions(-) diff --git a/bin/__build_sgr_code b/bin/__build_sgr_code index f8ffe17..b28fee8 100755 --- a/bin/__build_sgr_code +++ b/bin/__build_sgr_code @@ -7,9 +7,6 @@ # After that, we can map a few other special named symbols. The idea is to # permit shell variables such as `aaffcc bold italic` to indicate what you # want a format to look like. -# -# TODO: Update the script to allow for `bg:ff00ff` style descriptions, instead -# of positional. debug=0 From 79a53820597f05667e62033a77182e16a5245141 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 4 Jun 2022 10:12:09 -0400 Subject: [PATCH 12/35] Fix cyan! --- bin/__build_sgr_code | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/__build_sgr_code b/bin/__build_sgr_code index b28fee8..70360d5 100755 --- a/bin/__build_sgr_code +++ b/bin/__build_sgr_code @@ -45,7 +45,7 @@ map[vga-brown]="aa5500" map[vga-yellow]="aa5500" map[vga-blue]="0000aa" map[vga-magenta]="aa00aa" -map[vga-cyan]="aaaa00" +map[vga-cyan]="00aaaa" map[vga-white]="aaaaaa" map[vga-brightblack]="555555" From f4a65f9a8b7184e287a66ac496326f65f2fdca07 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 4 Jun 2022 10:12:46 -0400 Subject: [PATCH 13/35] Show colors in all possible modes in dump. --- bin/__build_sgr_code | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/bin/__build_sgr_code b/bin/__build_sgr_code index 70360d5..6015727 100755 --- a/bin/__build_sgr_code +++ b/bin/__build_sgr_code @@ -70,7 +70,21 @@ function dump_colors() { for key in ${!map[@]} do - printf "%-24s${map[${key}]} |`$0 reset reverse fg:${key}`sample`$0 reset`|\n" ${key} + printf "%-24s${map[${key}]} |" ${key} + printf "`$0 reset reverse fg:${key}`native-sample`$0 reset`|" + if [[ ! -v CSHENV_TERMINAL_COLORS ]] || (( ${CSHENV_TERMINAL_COLORS} >= 256 )) + then + printf "`env CSHENV_TERMINAL_COLORS=256 $0 reset reverse fg:${key}`8-bit sample`$0 reset`|" + fi + if [[ ! -v CSHENV_TERMINAL_COLORS ]] || (( ${CSHENV_TERMINAL_COLORS} >= 16 )) + then + printf "`env CSHENV_TERMINAL_COLORS=16 $0 reset reverse fg:${key}`4-bit sample`$0 reset`|" + fi + if [[ ! -v CSHENV_TERMINAL_COLORS ]] || (( ${CSHENV_TERMINAL_COLORS} >= 8 )) + then + printf "`env CSHENV_TERMINAL_COLORS=8 $0 reset reverse fg:${key}`3-bit sample`$0 reset`|" + fi + printf "\n" done exit 0 From 6d2fa26e6c0911449fcffa28a46864cf5715cfda Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 4 Jun 2022 10:16:02 -0400 Subject: [PATCH 14/35] Clean up a comment. --- bin/__build_sgr_code | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/__build_sgr_code b/bin/__build_sgr_code index 6015727..8005d92 100755 --- a/bin/__build_sgr_code +++ b/bin/__build_sgr_code @@ -294,8 +294,7 @@ function rgb_color() fi # We do NOT check for the base colours precisely. Since those 16 can be custom mapped by your terminal emulator, you just pass `ansi:0` thru - # `ansi:15` to select them by ID. Or use `ext:0` thru `ext:255` to select a specific extended colour. Otherwise, we now generate the true-colour - # result: + # `ansi:15` to select them by ID. Or use `ext:0` thru `ext:255` to select a specific extended colour. } function make_color() From b91fa6c8912b853909b23a75ae4402c2736b1ec0 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 4 Jun 2022 10:16:30 -0400 Subject: [PATCH 15/35] Special case brown mapping --- bin/__build_sgr_code | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/bin/__build_sgr_code b/bin/__build_sgr_code index 8005d92..9c72189 100755 --- a/bin/__build_sgr_code +++ b/bin/__build_sgr_code @@ -220,6 +220,23 @@ function rgb_color() echo "Intensity bit: " $intensity_1_bit fi + + # Because brown is tricky, I'm going to special case it: + if (( ${red_dec} > 128 && ${green_dec} > 80 && ${blue_dec} < 50 )) + then + red_1_bit=1 + green_1_bit=1 + blue_1_bit=0 + fi + + if (( ${debug} != 0 )) + then + echo "Red bit: " $red_1_bit + echo "Green bit: " $green_1_bit + echo "Blue bit: " $blue_1_bit + echo "Intensity bit: " $intensity_1_bit + fi + # This lets us combine them for a legacy colour value in the legacy colour space... legacy_3_bit=$(( ( ${blue_1_bit} << 2 ) + ( ${green_1_bit} << 1 ) + ( ${red_1_bit} ) )) From 2737fbb2884eb4874985655a57235241ca832e3f Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 4 Jun 2022 10:18:07 -0400 Subject: [PATCH 16/35] Special case grey --- bin/__build_sgr_code | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bin/__build_sgr_code b/bin/__build_sgr_code index 9c72189..a963409 100755 --- a/bin/__build_sgr_code +++ b/bin/__build_sgr_code @@ -221,6 +221,15 @@ function rgb_color() fi + # Because grey is tricky, I'm going to special case it: + if (( 1 && ${red_dec} == ${green_dec} && ${green_dec} == ${blue_dec} && ${red_dec} < 128 && ${red_dec} >= 80 )) + then + red_1_bit=0 + green_1_bit=0 + blue_1_bit=0 + intensity_1_bit=1 + fi + # Because brown is tricky, I'm going to special case it: if (( ${red_dec} > 128 && ${green_dec} > 80 && ${blue_dec} < 50 )) then 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 17/35] 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 18/35] 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 d0b12731e7472c91bf7e566e8e2aeea153da185c Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 4 Jun 2022 16:09:58 -0400 Subject: [PATCH 19/35] Clean up greys a bit, due to 16-base colours being user-mapped. --- bin/__build_sgr_code | 58 ++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/bin/__build_sgr_code b/bin/__build_sgr_code index a963409..1b101b7 100755 --- a/bin/__build_sgr_code +++ b/bin/__build_sgr_code @@ -59,6 +59,8 @@ map[vga-brightmagenta]="ff55ff" map[vga-brightcyan]="55ffff" map[vga-brightwhite]="ffffff" +enable_greyscale_cheat=0 + nocsi=0 if [[ $1 == "no-csi" ]] then @@ -70,19 +72,24 @@ function dump_colors() { for key in ${!map[@]} do + case $key in + *bright*) text_color="000000" ;; + *black*) text_color="ffffff" ;; + *) text_color="000000" ;; + esac printf "%-24s${map[${key}]} |" ${key} - printf "`$0 reset reverse fg:${key}`native-sample`$0 reset`|" + printf "`$0 reset reverse bg:${text_color} fg:${key}`native-sample`$0 reset`|" if [[ ! -v CSHENV_TERMINAL_COLORS ]] || (( ${CSHENV_TERMINAL_COLORS} >= 256 )) then - printf "`env CSHENV_TERMINAL_COLORS=256 $0 reset reverse fg:${key}`8-bit sample`$0 reset`|" + printf "`env CSHENV_TERMINAL_COLORS=256 $0 reset reverse bg:${text_color} fg:${key}`8-bit sample`$0 reset`|" fi if [[ ! -v CSHENV_TERMINAL_COLORS ]] || (( ${CSHENV_TERMINAL_COLORS} >= 16 )) then - printf "`env CSHENV_TERMINAL_COLORS=16 $0 reset reverse fg:${key}`4-bit sample`$0 reset`|" + printf "`env CSHENV_TERMINAL_COLORS=16 $0 reset reverse bg:${text_color} fg:${key}`4-bit sample`$0 reset`|" fi if [[ ! -v CSHENV_TERMINAL_COLORS ]] || (( ${CSHENV_TERMINAL_COLORS} >= 8 )) then - printf "`env CSHENV_TERMINAL_COLORS=8 $0 reset reverse fg:${key}`3-bit sample`$0 reset`|" + printf "`env CSHENV_TERMINAL_COLORS=8 $0 reset reverse bg:${text_color} fg:${key}`3-bit sample`$0 reset`|" fi printf "\n" done @@ -289,28 +296,31 @@ function rgb_color() echo "Computed 256 color choice, after applying greyscale scan: " ${ext_8_bit} fi - # Check for SPECIFIC white and black and grey: - # The half-saturation, no saturation, and full saturation values are mapped - # to specific points in the legacy set. (This may be ill-advised as a manually - # built reverse video terminal setting through colour mapping may make it so that - # we wind up in la-la land. Perhaps the better way is to find the head and tail - # points in the 6x6x6 colour cube.) - # - # TODO: Only map the head and tail of the colour cube. - if (( ${red_dec} == ${green_dec} && ${green_dec} == ${blue_dec} )) + if (( ${enable_greyscale_cheat} )) then - if (( ${red_dec} == 0 )) + # Check for SPECIFIC white and black and grey: + # The half-saturation, no saturation, and full saturation values are mapped + # to specific points in the legacy set. (This may be ill-advised as a manually + # built reverse video terminal setting through colour mapping may make it so that + # we wind up in la-la land. Perhaps the better way is to find the head and tail + # points in the 6x6x6 colour cube.) + # + # TODO: Only map the head and tail of the colour cube. + if (( ${red_dec} == ${green_dec} && ${green_dec} == ${blue_dec} )) then - ext_8_bit=0 - elif (( ${red_dec} == 255 )) - then - ext_8_bit=15 - elif (( ${red_dec} == 128 )) - then - ext_8_bit=8 - elif (( ${red_dec} == 192 )) - then - ext_8_bit=7 + if (( ${red_dec} == 0 )) + then + ext_8_bit=0 + elif (( ${red_dec} == 255 )) + then + ext_8_bit=15 + elif (( ${red_dec} == 128 )) + then + ext_8_bit=8 + elif (( ${red_dec} == 192 )) + then + ext_8_bit=7 + fi fi fi From d8b79c403433c2adbaaeeaaef3e975780368f572 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 4 Jun 2022 20:37:02 -0400 Subject: [PATCH 20/35] Remove unused alias. --- tcshrc.colors | 3 --- 1 file changed, 3 deletions(-) diff --git a/tcshrc.colors b/tcshrc.colors index 79a890b..a2eeade 100644 --- a/tcshrc.colors +++ b/tcshrc.colors @@ -77,9 +77,6 @@ set bright_white="$csi$ansi_bright;$ansi_white$ansi_color" # 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 - ########################### # vim:filetype=tcsh From 348c0af58c90587c0f818358d8fa471078f51b8f Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 4 Jun 2022 23:40:37 -0400 Subject: [PATCH 21/35] Report errors that were originally silent. --- bin/__build_sgr_code | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bin/__build_sgr_code b/bin/__build_sgr_code index 1b101b7..74d9f14 100755 --- a/bin/__build_sgr_code +++ b/bin/__build_sgr_code @@ -116,7 +116,7 @@ function setup_color_depth() then use_3_bit=1 else - exit -1 + echo "ERROR!" 1>&2 ; exit -1 fi fi } @@ -149,7 +149,7 @@ function ansi_color() { if (( ${1} > 15 )) then - exit -1 + echo "ERROR!" 1>&2 ; exit -1 elif (( ${1} >= 8 )) then use_4_bit=1 @@ -165,10 +165,9 @@ function ansi_color() function ext_color() { use_8_bit=1 - selection=${1:4} if (( ${1} > 255 )) then - exit -1 + echo "ERROR!" 1>&2 ; exit -1 else ext_8_bit=${1} fi From 69f9e98e61b2c80a1eca17f5908fb8df664666ba Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 4 Jun 2022 23:42:02 -0400 Subject: [PATCH 22/35] Turn the main engine into a function. --- bin/__build_sgr_code | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/__build_sgr_code b/bin/__build_sgr_code index 74d9f14..a766c26 100755 --- a/bin/__build_sgr_code +++ b/bin/__build_sgr_code @@ -352,10 +352,8 @@ function named_color() rgb_color ${mapped} } -output="" - -while [[ ! -z $1 ]] -do +function build_sgr_code() +{ case $1 in dump-colors) dump_colors ;; @@ -399,6 +397,12 @@ do output="${output};" fi output="${output}${next}" +} + +output="" +while [[ ! -z $1 ]] +do + build_sgr_code $1 shift 1 done From 138e494ffbd9ac0cca3d2582646435968d5213a2 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 4 Jun 2022 23:42:12 -0400 Subject: [PATCH 23/35] Added greyscale and rgb options for `ext:` colours. --- bin/__build_sgr_code | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/bin/__build_sgr_code b/bin/__build_sgr_code index a766c26..e38c0de 100755 --- a/bin/__build_sgr_code +++ b/bin/__build_sgr_code @@ -162,6 +162,26 @@ function ansi_color() fi } +function ext_grey() +{ + use_8_bit=1 + grey_val=${1} + if (( ${grey_val} < 0 || ${grey_val} > 23 )) + then + echo "ERROR!" 1>&2 ; exit -1 + fi + ext_8_bit=$(( 232 + ${grey_val} )) +} + +function ext_rgb() +{ + use_8_bit=1 + red_ext_val=$((6#${1:0:1})) + green_ext_val=$((6#${1:1:1})) + blue_ext_val=$((6#${1:2:1})) + ext_8_bit=$(( 16 + 36 * ${red_ext_val} + 6 * ${green_ext_val} + ${blue_ext_val} )) +} + function ext_color() { use_8_bit=1 @@ -371,18 +391,24 @@ function build_sgr_code() reveal) next=28 ;; ansi:*) make_color 0 ansi_color ${1:5} ;; + ext:grey*) make_color 0 ext_grey ${1:8} ;; + ext:rgb*) make_color 0 ext_rgb ${1:7} ;; ext:*) make_color 0 ext_color ${1:4} ;; # 12-bit color also supported [0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]) make_color 0 rgb_color $1 ;; [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 0 rgb_color $1 ;; fg:ansi:*) make_color 0 ansi_color ${1:8} ;; + fg:ext:grey*) make_color 0 ext_grey ${1:11} ;; + fg:ext:rgb*) make_color 0 ext_rgb ${1:10} ;; fg:ext:*) make_color 0 ext_color ${1:7} ;; # 12-bit color also supported fg:[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]) make_color 0 rgb_color ${1:3} ;; fg:[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 0 rgb_color ${1:3} ;; bg:ansi:*) make_color 1 ansi_color ${1:8} ;; + bg:ext:grey*) make_color 1 ext_grey ${1:11} ;; + bg:ext:rgb*) make_color 1 ext_rgb ${1:10} ;; bg:ext:*) make_color 1 ext_color ${1:7} ;; # 12-bit color also supported bg:[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]) make_color 1 rgb_color ${1:3} ;; 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 24/35] 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 25/35] 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 26/35] 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 27/35] 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 28/35] 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 29/35] 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 30/35] 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 31/35] 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 32/35] 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 33/35] 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 34/35] 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 From b3157c76a87bd33cf21fbaeff7eba9f8964227bf Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sun, 5 Jun 2022 23:28:06 -0400 Subject: [PATCH 35/35] Adding session support. --- tcshrc | 21 ++++++++++++++++++++- tcshrc.prompt.final | 10 ++++++++++ tcshrc.session.default | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 tcshrc.session.default diff --git a/tcshrc b/tcshrc index 1fe0c4d..9be9074 100644 --- a/tcshrc +++ b/tcshrc @@ -52,12 +52,26 @@ if( $?CSHENV_HISTORY_SIZE ) then set history=${CSHENV_HISTORY_SIZE} endif -# this safe_source alias is incredibly delicate. It drives the whole +if( $?CSHENV_DEBUG ) echo "Setting up optional sourcing mechanism." +# This safe_source alias is incredibly delicate. It drives the whole # optional sourcing mechanism -- DO NOT MESS WITH IT! alias safe_source 'eval "if ( -f \!:1 ) then \\ source \!:1 \\ endif"' +if( $?CSHENV_DEBUG ) echo "Setting up optional session sourcing mechanism." +# These reload_session and `__load_session` aliases ar incredibly delicate. They drives +# the whole optional session mechanism -- DO NOT MESS WITH IT LIGHTLY! +alias __load_session safe_source tcshrc.session.\$CSHENV_SESSION_PROFILE +if( $?CSHENV_DEBUG ) echo "Setting up optional session sourcing mechanism wrapper." +alias reload_session 'eval "if ( \$?CSHENV_SESSION_PROFILE ) then \\ +__load_session \\ +endif"' + +if( $?CSHENV_DEBUG ) echo "Setting change session alias..." +alias change_session setenv CSHENV_SESSION_PROFILE \!:1\;__load_session + + if( $?CSHENV_DEBUG ) then echo "TCSH safe-source alias constructed..." endif @@ -123,6 +137,11 @@ source ${CSHENV_DIR}/tcshrc.prompt safe_source ${CSHENV_DIR}/tcshrc.user +if( $?CSHENV_DEBUG ) echo "Loading session, if one is set" +reload_session +if( $?CSHENV_DEBUG ) echo "Session loading done" + + ########################### # vim: ft=tcsh ########################### diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index db9c1e6..58602c9 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -2,6 +2,16 @@ ### Final Prompt Setting ### ############################ +#if( $?CSHENV_DEBUG ) then +# echo "Loading prompt session information." +#endif +#if( $?CSHENV_SESSION_PROFILE ) then +# safe_source ${CSHENV_DIR}/tcshrc.session.prompt.${CSHENV_SESSION_PROFILE} +#endif +#if( $?CSHENV_DEBUG ) then +# echo "Loaded prompt session information." +#endif + if( $?CSHENV_DEBUG ) then echo "Setting up dynamic colour loading..." endif diff --git a/tcshrc.session.default b/tcshrc.session.default new file mode 100644 index 0000000..b9e73a4 --- /dev/null +++ b/tcshrc.session.default @@ -0,0 +1 @@ +source ${CSHENV_DIR}/tcshrc.prompt.colors