Merge branch 'master' of github.com:adamlsd/cshenv

This commit is contained in:
2022-06-09 18:08:22 -04:00
7 changed files with 709 additions and 52 deletions

455
bin/__build_sgr_code Executable file
View File

@ -0,0 +1,455 @@
#!/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.
#
# 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.
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[grey]="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"
# 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]="00aaaa"
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"
enable_greyscale_cheat=0
nocsi=0
if [[ $1 == "no-csi" ]]
then
nocsi=1
shift 1
fi
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 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 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 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 bg:${text_color} fg:${key}`3-bit sample`$0 reset`|"
fi
printf "\n"
done
exit 0
}
function setup_color_depth()
{
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
echo "ERROR!" 1>&2 ; exit -1
fi
fi
}
function render_color()
{
command_color=30
if (( ${use_3_bit} ))
then
# 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} ))"
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
echo "ERROR!" 1>&2 ; exit -1
elif (( ${1} >= 8 ))
then
use_4_bit=1
intensity_1_bit=1
legacy_3_bit=$(( ${1} - 8 ))
else
use_3_bit=1
intensity_1_bit=0
legacy_3_bit=$(( ${1} ))
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
if (( ${1} > 255 ))
then
echo "ERROR!" 1>&2 ; exit -1
else
ext_8_bit=${1}
fi
}
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=${color:0:2}
green_hex=${color:2:2}
blue_hex=${color: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
# 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
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} ) ))
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
if (( ${enable_greyscale_cheat} ))
then
# 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
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.
}
function make_color()
{
setup_color_depth
background=$1 # $1 is the background bit
$2 $3 # $2 is the color function
render_color
}
function named_color()
{
name=${1,,}
if [[ ! -v map[$name] ]]
then
echo "ERROR!" 1>&2 ; exit -1
fi
mapped=${map[$name]}
rgb_color ${mapped}
}
function build_sgr_code()
{
case $1 in
dump-colors) dump_colors ;;
reset) next=0 ;;
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 ;;
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} ;;
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} ]]
then
output="${output};"
fi
output="${output}${next}"
}
output=""
while [[ ! -z $1 ]]
do
build_sgr_code $1
shift 1
done
if [[ ! -z ${output} ]] && (( ! ${nocsi} ))
then
output="[${output}m"
fi
if [[ ! -z ${output} ]]
then
printf ${output}
fi
exit 0

21
tcshrc
View File

@ -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
###########################

View File

@ -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,24 @@ 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: `__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 colour and a weaker rounded form for use
# with 3 and 4 bit colour. It does this based upon your terminal colour depth.
set sgr_reset="[`__build_sgr_code no-csi reset`m"
###########################
# vim:filetype=tcsh

View File

@ -2,40 +2,25 @@
### 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="${dim_magenta}"
set time_color="${bright_magenta}"
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 line_color="${dim_red}"
set prompt_color="${dim}"
set depth_color="${dim_yellow}"
set command_color="${dim}"
set date_color="ansi:5"
set time_color="ansi:13"
set text_color="reset"
set brace_color="ansi:11"
set host_color="ansi:12"
set user_color="ansi:14"
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 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}"
set command_color_seq="${color_start}${command_color}${color_end}"
set oldp_color="${color_start}${dim_white}${color_end}"
alias load_default_prompt_colors source ${CSHENV_DIR}/tcshrc.prompt.colors
###########################
# vim:filetype=tcsh

View File

@ -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 )
@ -116,16 +117,15 @@ 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.
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
@ -133,19 +133,15 @@ 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="(${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 path_prompt="${path_color_seq}%c02"
set end_prompt="${prompt_color_seq}%#${command_color_seq} "
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"
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'

View File

@ -1,6 +1,132 @@
############################
### 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
# 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
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
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
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%}"
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
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}%}"
endif
if( ! $?curr_time_color ) then
set curr_time_color=impossible
endif
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( ! $?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( ! $?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( ! $?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( $?CSHENV_DEBUG ) echo "Dynamic color loading processed..."
if( ${prompt_hcolor} != 0 ) then
set last_color = ${reference_colors[${prompt_hcolor}]}
endif
@ -18,6 +144,7 @@ set medium_battery_level = 50
set strong_battery_level = 75
while( ${prompt_hcolor} == 0 )
if( $?CSHENV_DEBUG ) then
echo colorshuffle
@ -110,7 +237,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=""
@ -132,9 +259,9 @@ 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="%{${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
@ -142,7 +269,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_color_seq}${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_color_seq}${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_color_seq}${user_prompt}%{${sgr_reset}%}"
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_color_seq}${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_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}%}${prompt_color_seq}${end_prompt}%{${sgr_reset}${text_color_seq}%} "
if( ! ${?cshenv_user_prompt_override} ) then
set prompt="$prompt_cool"

1
tcshrc.session.default Normal file
View File

@ -0,0 +1 @@
source ${CSHENV_DIR}/tcshrc.prompt.colors