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?

  • I'm not really understanding how eval "dircolors -b" would ever display the output in color. eval doesn't do any handling on the output of the commands. Commented Oct 23, 2012 at 11:02
  • This is what I recall; I might be wrong. If not that command, then some other similar command allowed me to see the extensions listed in the colours they would display in. That much I remember seeing. The question is what command shows output similar to dircolors but in the respective colours? Sorry for the bother.
    – chandra
    Commented Oct 23, 2012 at 11:31
  • Might be of interest: unix.stackexchange.com/questions/20721/testing-ls-colors-in-zsh Commented Oct 23, 2012 at 21:52
  • @Stéphane Gimenez: Your expansion of abbreviations at that weblink is very helpful. I have three abbreviations, rs, ca, and mh that are not included above. Can you please tell me where to find their expansions? Thanks
    – chandra
    Commented Oct 26, 2012 at 18:25

2 Answers 2


Try this script:

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


output screenshot

  • Thank you. I remember only the file extensions showing up in their respective colours. I need to do some digging up to understand what IFS is though.
    – chandra
    Commented Oct 23, 2012 at 18:48

This version has some additional information and doesn't color the entire lines:

eval $(echo "no:global default;fi:normal file;di:directory;ln:symbolic link;pi:named pipe;so:socket;do:door;bd:block device;cd:character device;or:orphan symlink;mi:missing file;su:set uid;sg:set gid;tw:sticky other writable;ow:other writable;st:sticky;ex:executable;"|sed -e 's/:/="/g; s/\;/"\n/g')           
   for i in $LS_COLORS     
        echo -e "\e[${i#*=}m$( x=${i%=*}; [ "${!x}" ] && echo "${!x}" || echo "$x" )\e[m" 

Part of answer by @karthick87 on Askubuntu
Also, see this answer: What causes this green background in ls output?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .