14

When I run ls on a folder with directories that have a 777 permission, the ls colors are purple text with a green background, which is unreadable:

enter image description here

What can I do to make this more pleasant to look at?

21

If you are using Linux (and not, e.g., using a Mac which does things differently) you can use dircolors with a custom database to specify which colors are used for which file attributes.

First, create a dircolors database file.

$ dircolors -p > ~/.dircolors

Then edit it, you probably want to change the STICKY_OTHER_WRITABLE and OTHER_WRITABLE lines to something more pleasant than 34;42 (34 is blue, 42 is green - dircolors -p helpfully includes comments with the color codes listed).

Then run

eval $(dircolors ~/.dircolors)

Edit your ~/.profile (or ~/.bash_profile etc) and find the line that runs eval $(dircolors) and change it to include the filename as above. Or if there isn't such a line in your .profile (etc) add it.

Or, if you want it to work whether there is a ~/.dircolors file or not, change it to:

[ -e ~/.dircolors ] && eval $(dircolors -b ~/.dircolors) || 
    eval $(dircolors -b)
  • 2
    BTW, if you edit the .dircolors file with vim then vim's syntax highlighting will show you colours as you edit them. – cas Nov 9 '15 at 1:58
  • Is there a reason I should do do eval instead of just copying/pasting the result into my .bashrc? – JoshuaD Nov 9 '15 at 2:28
  • 1
    assuming you mean the output of dircolors -b and not dircolors -p (which isn't sh code): 1. to avoid bloating your .bashrc 2. so you can just edit ~/.dircolors rather than the far-less-readable output of dircolors -b. – cas Nov 9 '15 at 2:33
0

As a stopgap solution, you can use ls --color=never. (Works on CentOS, not sure about ls options on Cygwin; check man ls if it doesn't work.)

Also type alias, and if you see alias ls='ls --color=auto', you can run unalias ls to turn off automatic coloring of ls output. More permanent solutions (i.e. actually changing those colors instead of removing them) involve changing the colorization options for your terminal, but I'll leave that answering job for someone who actually knows how to do it....

Not the answer you're looking for? Browse other questions tagged or ask your own question.