Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Change 'ls' directory colors UNIX
If you run Terminal.app with a black background and a color 'ls' command, directories (in bold blue) can be hard to see. You can change the color of directories with an export LS_COLORS command. For example, to make all directories yellow, add this to ".bash_profile" in your home directory:
export LS_COLORS='di=01;33'
Other good colors for directories are bold white (01;37) and bold purple (01;35). You can find a complete table of ANSI colors in many places; The Linux Documentation Project's list is one such place.
    •    
  • Currently 4.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)
 
[36,160 views]  

Change 'ls' directory colors | 16 comments | Create New Account
Click here to return to the 'Change 'ls' directory colors' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Change 'ls' directory colors
Authored by: anakin513 on Mar 17, '03 12:29:57PM

Hmm.. didn't work for me. Couldn't find the export command.



[ Reply to This | # ]
Change 'ls' directory colors
Authored by: dylanjames on Mar 17, '03 12:43:50PM
"couldn't find export command" probably means you're not using bash. In that case, add
set LS_COLORS='di=01;33'
to your .tcshrc.

However, it didn't work for me either, and I am using bash.



[ Reply to This | # ]
Change 'ls' directory colors
Authored by: matsur on Mar 17, '03 01:21:11PM
The correct command for tcsh
setenv LS_COLORS='di=01;33'


For sh/bash
LS_COLORS='di=01;33' ; export LS_COLORS



Cheers!

[ Reply to This | # ]
Change 'ls' directory colors
Authored by: TigerKR on Mar 17, '03 07:33:30PM

adding "setenv LS_COLORS='di=01;33'" to my .tcshrc file didn't do anything, even after restarting Terminal.app (I use tcsh).



[ Reply to This | # ]
Change 'ls' directory colors
Authored by: TigerKR on Mar 17, '03 07:34:41PM

not did "setenv LS_COLORS 'di=01;33'" work



[ Reply to This | # ]
Syntax depends on your shell
Authored by: pbx on Mar 17, '03 12:44:16PM

The instruction assume you are using the bash shell. In the default (tcsh) shell, the command you want is:

<tt>setenv LS_COLORS 'di=01;33'</tt>

and you can set it in ~/.tcshrc



[ Reply to This | # ]
Change 'ls' directory colors
Authored by: mrbiiggy on Mar 17, '03 12:56:47PM

no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jpg=01;35:*.png=01;35:*.gif=01;35:*.bmp=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.png=01;35:*.mpg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:

That's what I use for my ls_colors. It doesn't look that great in OS X (and probably never will, anyways).



[ Reply to This | # ]
Change 'ls' directory colors
Authored by: athagon on Mar 17, '03 01:03:49PM

I tried the tcsh equivalent in my .tcshrc, but it didn't do anything.

---
"That which does not kill me makes me stronger." - Friedrich Nietzsche



[ Reply to This | # ]
Change 'ls' directory colors
Authored by: jyncroft on Mar 19, '03 01:25:24AM

For those that aren't getting this to work, you probably need to add an alias to your startup files along the lines of:

alias ls='ls -FsC --color=auto' # for zsh (or sh derivative)

alias ls 'ls -FsC --color=auto' # for csh derivatives

It's the --color=auto that's important. And, I don't think you have this option with the default ls command found in /bin/ls. You'll need to install a different one, like the one from fink (install the fileutils package).

Good luck, Jennifer



[ Reply to This | # ]
Change 'ls' directory colors
Authored by: jimr on Mar 19, '03 09:24:14AM

Jennifer (jyncroft) is right. or for the adventurous, compile the Gnu fileutils 4-1. It is easy, and will give you some experience compiling (with the Dev tools installed and with the idea that you might want to discover what the package installs and then backup all your old utils first).

All of the comments on this add up to the fact that:

"THIS IS NOT A GOOD HINT!"

As far as I know... the version of ls which ships with Mac OS X does not support the 'color=auto' command which you need to invoke when you are using ls. The version in the GNU tools ( search for fileutil in google ) includes that capability. This information has been provided in some hints previously on this web-site.

Fileutils also includes a small script that you can use to automatically set your environment variable it is called DIRCOLORS and you can make it executable and then setenv LS_COLORS 'path/to/DIRCOLORS'

this is desirable because a nice set of color choices may end up being a very long list.
here is a sample from my environment.mine (there is a hint about that too!!!) where I am not using the DIRCOLORS but obtained some of the information from there and then wrote the infor in multiple lines as follows:

each setenv LS_COLORS "XXXX:XXXX" should be on one line!!!

setenv LS_COLORS "no=00:fi=00:di=09;33:ln=04;34:pi=04;33:*.dylib=04;03;31"
setenv LS_COLORS "${LS_COLORS}:so=01;35:bd=03;32;03:cd=03;34;02:or=30;01;31"
setenv LS_COLORS "${LS_COLORS}:ex=03;36:*.tar=04;03;32:*.tgz=04;03;32"
setenv LS_COLORS "${LS_COLORS}:*.arj=01;31:*.taz=01;31:*.lzh=01;30"
setenv LS_COLORS "${LS_COLORS}:*.zip=35;01;30:*.z=01;31:*.Z=01;30:*.gz=04;03;32"
setenv LS_COLORS "${LS_COLORS}:*.d*=01;30:*.jpg=01;35:*.gif=04;32"
setenv LS_COLORS "${LS_COLORS}:*.pl=06;31:*.ppm=01;35:*.tga=01;35"
setenv LS_COLORS "${LS_COLORS}:*.xbm=01;35:*.xpm=01;35:*.ti*=01;34"
setenv LS_COLORS "${LS_COLORS}:*.txt=09;33:*.pdf=02;36:*.gl=03;37:*.dl=01;37"
setenv LS_COLORS "${LS_COLORS}:*.mine=03;36:*.html=02;34:*.cgi,*.?html=03;34"

If you just want to get away from the default blue for directories try to find the correct way for your shell in the other comments in this section.

so find a copy of color_ls (for example: -HERE- and check which shell you are using and you too, can have an easy to read terminal display. you will need to change the name to ls!!!! (also, sometimes my router takes a little walk in the park....)

---
Jimr
--Tokyo--

[ Reply to This | # ]

Change 'ls' directory colors
Authored by: DMCrimson on Apr 08, '03 02:03:00PM

to get it working, one needs to install GNU fileutils (better versions of chgrp, chmod, chown, cp, dd, df, dir, dircolors, du, install, ln, ls, mkdir, mkfifo, mknod, mv, rm, rmdir, shred, sync, touch, and vdir) BUT version 4.1 has a bug in dircolors, so color for "DOOR" should be left undefined in LS_COLORS... found it out today, tried to recompile, but no go...



[ Reply to This | # ]
Change 'ls' directory colors
Authored by: bluehz on Apr 09, '03 08:41:29AM

Whenever I have tried using colors - in particular colors in ls ... my terminal slows to a crawl. You wouldn't think simple colors would do that - but it does.



[ Reply to This | # ]
Change 'ls' directory colors
Authored by: clabough on May 02, '03 03:38:59AM

I noticed that too. But everything in Terminal is slow. Try
scrolling through the dselect listings! If you use a terminal app
in X11/XDarwin/etc. then ls and dselect will fly by.



[ Reply to This | # ]
Change 'ls' directory colors
Authored by: endocet on Jul 18, '03 09:31:43PM
my terminal app seems to be very quick. never had any problems with it. i proved it to myself by executing find /

[ Reply to This | # ]
Change 'ls' directory colors
Authored by: lovethedj on Feb 04, '04 05:30:52PM

for those wishing to change the colors from the default ones chosen by Panther, it is pretty simple...

1) open the color picker (cmd+shift+c)
2) choose a color
3) drag and drop the color swatch to the text in the terminal which you want to change color of
- all text of this type will then change to this new color

- now if someone could just figure out how to make these modifications permanent (saved as the default values)

---



[ Reply to This | # ]
Change 'ls' directory colors
Authored by: lkravovicz on Nov 25, '08 05:43:00AM

leopard's man ls gives the following info:

LSCOLORS The value of this variable describes what color to use for which attribute when colors are enabled with CLICOLOR. This
string is a concatenation of pairs of the format fb, where f is the foreground color and b is the background color.

...

and so forth.

export LSCOLORS='Exfxcxdxbxegedabagacad'

gave me the lighter blue directories that i was looking for. now the line lives in my /etc/bashrc



[ Reply to This | # ]