Make LS_COLORS dynamic via __build_sgr_code.

This commit is contained in:
2026-06-28 01:42:50 -04:00
parent 79d6e087ce
commit 51eca1ca94
2 changed files with 89 additions and 5 deletions
+1 -5
View File
@@ -89,11 +89,7 @@ source ${CSHENV_DIR}/tcshrc.system
#For GNU ls(1) {From coreutils} and tcsh's color ls-F
#Also, coming soon, my port of ls-F highlighting to FreeBSD's
#ls(1) -G facility
if( $?CSHENV_LINUX_SUCKS ) then
setenv LS_COLORS 'no=00:fi=00:di=01;34:ln=01;35:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;41;37:ex=00;31:*.tar=01;31:*.tgz=01;31:*.tbz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jpg=01;35:*.png=01;35:*.gif=01;35:*.bmp=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.png=01;35:*.mpg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.cpp=32:*.cc=32:*.c=32:*.l=32:*.cxx=32:*.hpp=33:*.h=33:*.i=33:*.a=31:*.asm=31:*.bin=35:*.sec=36:*.ko=31'
else
setenv LS_COLORS 'no=00:fi=00:di=01;34:ln=01;35:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=01;05;41;37:ex=00;31:*.tar=01;31:*.tgz=01;31:*.tbz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.zst=01;31:*.lz4=01;31:*.deb=01;31:*.rpm=01;31:*.jpg=01;35:*.png=01;35:*.gif=01;35:*.bmp=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.png=01;35:*.mpg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.cpp=32:*.cc=32:*.c=32:*.l=32:*.m=32:*.i=33:*.cxx=32:*.h=33:*.hpp=33:*.a=31:*.asm=31:*.bin=35:*.sec=36:*.ko=31'
endif
source ${CSHENV_DIR}/tcshrc.lscolors
setenv CLICOLOR_FORCE
+88
View File
@@ -0,0 +1,88 @@
#######################################
# CSHENV Colors for gnu compatible LS #
#######################################
set cshenv_c_source="italic ext:2"
set cshenv_c_header="italic ext:3"
set cshenv_archive="ext:9 doubleunder"
set cshenv_image="bold ext:5"
set cshenv_ls_colors=\
( \
.sh=ansi:5 \
no=reset # Normal \
fi=reset # File? \
ex=under,ul:ext:1,ansi:1,italic # Executable \
ln=bold,ansi:13 # Link \
so=bold,ansi:5,italic # Socket \
di=ext:4,bold # Directory \
bd=bg:ext:14,fg:ext:0,bold # Block Device \
cd=bg:ext:11,fg:ext:0,italic # Character Device \
or=blink,bg:ext:1,fg:ext:15,bold,strike,doubleunder,ul:ext:0 # Broken symlink\
\
.a=ansi:1 \
.asm=ansi:1 \
.bin=ansi:5 \
.sec=ansi:6 \
.ko=ansi:1 \
.deb=italic,underline,ansi:11 \
.rp=italic,underline,ansi:11 \
)
set cshenv_source_files=( c cpp cc cxx C )
set cshenv_header_files=( h hpp hh hxx H )
set cshenv_archive_files=( tar tgz tbz arj taz lzh zip z Z gz bz2 zst lz4 )
set cshenv_image_files=( jpg png gif bmp ppm tga xbm xpm tif png webm )
foreach kind ( ${cshenv_source_files} )
set hl="${cshenv_c_source}"
if ( ${kind} != c ) then
set hl="${hl} underline"
endif
set cshenv_ls_colors=( ${cshenv_ls_colors} .${kind}=${hl:as/ /,/} )
end
foreach kind ( ${cshenv_header_files} )
set hl="${cshenv_c_header}"
if ( ${kind} != h ) then
set hl="${hl} underline"
endif
set cshenv_ls_colors=( ${cshenv_ls_colors} .${kind}=${hl:as/ /,/} )
end
foreach kind ( ${cshenv_archive_files} )
set hl="${cshenv_archive}"
set cshenv_ls_colors=( ${cshenv_ls_colors} .${kind}=${hl:as/ /,/} )
end
foreach kind ( ${cshenv_image_files} )
set hl="${cshenv_image}"
set cshenv_ls_colors=( ${cshenv_ls_colors} .${kind}=${hl:as/ /,/} )
end
#### Old form
setenv LS_COLORS 'pi=40;33:do=01;35:*.mpg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35'
foreach color ( ${cshenv_ls_colors} )
_debug "${color}"
set split=( ${color:as/=/ /} )
set match="${split[1]:s/./*./}"
set args="${split[2]}"
#_debug "Split: ${split}"
#_debug "First: ${split[1]}"
_debug "Match: ${match}"
_debug "Match: ${match:as/./*./}"
_debug "Args: ${args}"
_debug "${args:as/,/ /}"
if ( $?CSHENV_DEBUG ) then
_debug __build_sgr_code no-csi "${args:as/,/ /}"
endif
set codes=`__build_sgr_code no-csi ${args:as/,/ /}`
setenv LS_COLORS "${LS_COLORS}:${match}=${codes}"
end
###########################
# vim: ft=tcsh
###########################