LS Colors – How to List LS_COLORS in Colour

colorsls

I recall that eval "dircolors -b" used to display the colours that LS_COLORS was using, based on the file types or extensions. It was not simply the colour values that were displayed but the colours themselves. I could see the colour in which a .png or .ogg file would be displayed and change it if needed through a custom file.

I find that the output of eval "dircolors -b" is no more in colour.

Can someone kindly explain how I might get it back? Perhaps some environment variable is not getting set. Otherwise, is there a workaround?

Best Answer

Try this script:

( # Run in a subshell so it won't crash current color settings
    dircolors -b >/dev/null
    IFS=:
    for ls_color in ${LS_COLORS[@]}; do # For all colors
        color=${ls_color##*=}
        ext=${ls_color%%=*}
        echo -en "\E[${color}m${ext}\E[0m " # echo color and extension
    done
    echo
)

Output:

output screenshot

Related Question