Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm trying to set up my color scheme for ls, and I'm having trouble finding information about exactly what parameters I have to work with, or where those come from. And especially setting colors for types of files instead of based on filetype.

For example, this is my current color scheme:
LS_COLORS='di=34;01:fi=0:ln=96;1:pi=36;1:so=31;1:bd=5:cd=5:or=31:mi=0:ex=35'

I found those parameters (di, fi, etc) from a website tutorial. But where do those come from? Can I set custom ones? I know I can set colors like *.jpg=0 and such. But is there a way to do it based on types of files? I specifically want to set compressed file types, but if I have to do it by recognizing filetypes, I feel there's a better way.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Try the dircolors command. It can print the default colors to standard output. You can use this output to modify the defaults and generate a suitable "LS_COLORS=...-line" again with dircolors. Say you want all compressed files which are bright red by default to be bright green instead, then you'd do

dircolor -p > dircolors.txt
vim dircolors

then you scroll to the section including the compressed files and modify the values from 01;31 to 01;32. Then call

dircolors -b dircolors.txt

to generate the "LS_COLORS=..."-line for you with the modified values.

share|improve this answer
    
Ah. So it actuallly doesn't set the color based on the the actual file type, it does just check filetypes –  Falmarri Oct 10 '10 at 22:53
    
It sets the color based on the file extension –  PiedPiper Oct 10 '10 at 23:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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