I make following to this post : export-ls-colors-apply-the-rule-for-every-file-beginning-by-readme
I summarize the issue briefly:
eval `/opt/local/libexec/gnubin/dircolors ~/.dircolors`
export LS_COLORS="${LS_COLORS}*README=00;37;44"
Then, when creating a README
file, then I will get :
But now, I would like to apply the rule and do the same for every filename beginning by README (like README_something
, README_important
).
for this, I tried to put:
export LS_COLORS="${LS_COLORS}*README*=00;37;44"
but it is not displayed as above image (only white).
Potential solution
A potential solution would be to recompile ls
command from coreutils
sources package (I am on MacOS Big Sur 11.2.3).
The modification is located here :
https://github.com/wertarbyte/coreutils/blob/master/src/ls.c#L4206
I am looking into what modifications are required if I want the files README_string
where string
is any kind of string to be colorified by the command "l
" with the following alias in ~/.zshrc
:
alias l='grc -es --colour=auto ls --color -Gh -C -lrt'
How can I carry out this recompilation?
Edit
Below the part of the code that manages the colorifying of file (https://github.com/wertarbyte/coreutils/blob/master/src/ls.c#L4206 ):
/* Check the file's suffix only if still classified as C_FILE. */
ext = NULL;
if (type == C_FILE)
{
/* Test if NAME has a recognized suffix. */
len = strlen (name);
name += len; /* Pointer to final \0. */
for (ext = color_ext_list; ext != NULL; ext = ext->next)
{
if (ext->ext.len <= len
&& strncmp (name - ext->ext.len, ext->ext.string,
ext->ext.len) == 0)
break;
}
}
I would like the file without extension to be colorified. I have some notions of C language but not enough to understand what happens in this section of the code.
What modifications could I apply for getting colorifying without extension ?