I’m fine customizing most settings in LS_COLORS
. I don’t need help customizing the colors for different file suffixes. What I would like to do is configure special colors for certain directories, based on their suffix.
(For example, I’d like dir1/
to display in the standard directory color, but dir2.special-suffix/
to display in a different color, which I set for directories with names that end in .special-suffix
.)
I’ve tried to do this using the standard *.«suffix»
method (as used with files), but without luck. All directories are displayed in the color specified for di
, and ignore any subsequent *.«suffix»
rules.
Is this even possible?
Best Answer
Probably not, though this may have surprised the devs as well. Here's a comment from an excerpted GNU's ls.c:
Here is a link to the full ls.c source in which you will find the same, though it is not as pretty to read, maybe.
It is worth noting though you can get some alternation in color for directories based on their modes and/or depending on their link state. Of course, such things would amount to changing the contents of the report for sake of the reporter, but I'm no philosopher; so here's one way you might:
OUTPUT
And just to be sure such a thing wasn't a ludicrously dangerous idea, I did double-check with google about what the sticky bit does:
So if we're talking about your directories which are not things you intend to allow others to delete in the first place, probably there is no harm done.
P.S. If you're curious about what's going on with the
$LS_COLORS
definition there I covered it pretty well (I hope) here. I have also pasted in some more comments from the source below which I expect you will find align pretty well with the outputdircolors -p
will provide you (for the ones it bothers to also define, that is):