Open pagerc opened 4 years ago
I tried appending *rc 36m \e[36
to my ~/.dir_colors and running dircolors ~/.dir_colors
but this didnt change the behavior of ls.
Could you give some more direction on how you got this to work?
Update your configuration file to contain the appropriate mappings, e.g.
~/.dir_colors
LINK 01;36m \e[01;36 # symbolic link. (If you set this to 'target' instead of a
*rc 36m \e[36
In your shell startup, or paste into an existing shell to initialize the environment:
type dircolors >/dev/null 2>&1 && {
eval `{ dircolors -b "${XDG_CONFIG_HOME}/sh/dir_colors" 2>/dev/null || dircolors -b ~/.dir_colors || dircolors -p | dircolors -b ; } | sed '$d'`
}
COLOR_OPTS=${COLOR_OPTS:---color=auto}
alias ls="LS_COLORS=\${LS_COLORS:-${LS_COLORS}} ls \${COLOR_OPTS:-${COLOR_OPTS}} --group-directories-first --time-style=long-iso -h"
To fully explain what's going on:
ls
is typically provide by one of the following packages:
coreutils
busybox
toybox
Of these, only GNU coreutils ls
provides the LS_COLORS string parsing logic for modifying color codes by extension. The others will colorize output, but do so in a hardcoded fashion.
To use dircolors, you need GNU coreutils installed.
You got it working, sweet!
Cool, thanks for the explanation
As LS_COLORS is a non-POSIX extension to ls
, I recommend looking at exa for colorized directory listings.
Or if you're a GNU purist, check out this extensive list of colorings:
https://github.com/trapd00r/LS_COLORS
The original LS has dir_colors for generating the LS_COLORS attributes, which already supports console escape sequences which permits mapping unicode character sets to file types:
This for example, when the below is added to ~/.dir_colors, it will make all rc resource files light green in appearance and set the alpine linux icon when using NerdFonts: *rc 36m \e[36
I recommend updating the project/readme with the above details to assist in disseminating this information so that as a community we can focus on improving our file type mappings with contributions to https://github.com/trapd00r/LS_COLORS additional icon/color mappings.