Cached ls colors generation for some "groups"

This commit is contained in:
2026-07-30 02:25:49 -04:00
parent ef2dfef39f
commit e45befb52c
+40 -13
View File
@@ -2,6 +2,10 @@
# CSHENV Colors for gnu compatible LS # # CSHENV Colors for gnu compatible LS #
####################################### #######################################
#### Old form
set cshenv_computed_ls_colors='pi=40;33:do=01;35:*.mpg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35'
set cshenv_c_source="italic ansi:2" set cshenv_c_source="italic ansi:2"
set cshenv_c_header="italic ansi:3" set cshenv_c_header="italic ansi:3"
set cshenv_archive="ansi:9 doubleunder" set cshenv_archive="ansi:9 doubleunder"
@@ -35,36 +39,57 @@ 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_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 ) set cshenv_image_files=( jpg png gif bmp ppm tga xbm xpm tif png webm )
set _last=""
set _computed=""
foreach kind ( ${cshenv_source_files} ) foreach kind ( ${cshenv_source_files} )
set hl="${cshenv_c_source}" set hl="${cshenv_c_source}"
if ( ${kind} != c ) then #if ( ${kind} != c ) then
set hl="${hl} underline" #set hl="${hl} underline"
#endif
if( "${_last}" != "${hl}" ) then
set _computed="`__build_sgr_code no-csi ${hl}`"
endif endif
set cshenv_ls_colors=( ${cshenv_ls_colors} .${kind}=${hl:as/ /,/} ) set cshenv_computed_ls_colors="${cshenv_computed_ls_colors}:*.${kind}=${_computed}"
set _last="${hl}"
end end
set _last=""
set _computed=""
foreach kind ( ${cshenv_header_files} ) foreach kind ( ${cshenv_header_files} )
set hl="${cshenv_c_header}" set hl="${cshenv_c_header}"
if ( ${kind} != h ) then #if ( ${kind} != h ) then
set hl="${hl} underline" #set hl="${hl} underline"
#endif
if( "${_last}" != "${hl}" ) then
set _computed="`__build_sgr_code no-csi ${hl}`"
endif endif
set cshenv_ls_colors=( ${cshenv_ls_colors} .${kind}=${hl:as/ /,/} ) set cshenv_computed_ls_colors="${cshenv_computed_ls_colors}:*.${kind}=${_computed}"
set _last="${hl}"
end end
set _last=""
set _computed=""
foreach kind ( ${cshenv_archive_files} ) foreach kind ( ${cshenv_archive_files} )
set hl="${cshenv_archive}" set hl="${cshenv_archive}"
set cshenv_ls_colors=( ${cshenv_ls_colors} .${kind}=${hl:as/ /,/} ) if( "${_last}" != "${hl}" ) then
set _computed="`__build_sgr_code no-csi ${hl}`"
endif
set cshenv_computed_ls_colors="${cshenv_computed_ls_colors}:*.${kind}=${_computed}"
set _last="${hl}"
end end
set _last=""
set _computed=""
foreach kind ( ${cshenv_image_files} ) foreach kind ( ${cshenv_image_files} )
set hl="${cshenv_image}" set hl="${cshenv_image}"
set cshenv_ls_colors=( ${cshenv_ls_colors} .${kind}=${hl:as/ /,/} ) if( "${_last}" != "${hl}" ) then
set _computed="`__build_sgr_code no-csi ${hl}`"
endif
set cshenv_computed_ls_colors="${cshenv_computed_ls_colors}:*.${kind}=${_computed}"
set _last="${hl}"
end 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} ) foreach color ( ${cshenv_ls_colors} )
_debug "${color}" _debug "${color}"
set split=( ${color:as/=/ /} ) set split=( ${color:as/=/ /} )
@@ -79,10 +104,12 @@ foreach color ( ${cshenv_ls_colors} )
if ( $?CSHENV_DEBUG ) then if ( $?CSHENV_DEBUG ) then
_debug __build_sgr_code no-csi "${args:as/,/ /}" _debug __build_sgr_code no-csi "${args:as/,/ /}"
endif endif
set codes=`__build_sgr_code no-csi ${args:as/,/ /}` set codes="`__build_sgr_code no-csi ${args:as/,/ /}`"
setenv LS_COLORS "${LS_COLORS}:${match}=${codes}" set cshenv_computed_ls_colors="${cshenv_computed_ls_colors}:${match}=${codes}"
end end
setenv LS_COLORS "${cshenv_computed_ls_colors}"
########################### ###########################
# vim: ft=tcsh # vim: ft=tcsh
########################### ###########################