color ls!!!


Hey, for those of you bored out of your mind looking at the same old black on white or white on black scheme in the terminal, I have a new compiled color version of ls that will function perfectly with a few adjustments:
As root: (or using sudo which gets annoying)
- Download this:, uncompress it, and use the terminal to move it to /bin (the file's name should be ls2 unless you want to change the config proceeding these instructions accordingly)
- Type this into your terminal after moving the file: "chmod +x /bin/ls2" (just making sure you have priveledges to open it)
Additional adjustments:
1) Open up your /usr/share/init/tcsh/tcsh.defaults file with a text editor (pico is a good editor for newbies)
2) This line: "#alias ls 'ls-F'" should have a # (comment on it) at the beginning. If it's not there, add it with the #.
3) Add this line to the file: "alias ls '/bin/ls2 --color -a'" (make sure when you add lines, they go *before* the #endif, for obvious reasons)
4) Every new terminal window you open will show directories/files/links in their according colors from now on, if all went okay.
Cool! Thanks! I've been looking for that. By the way, if anyone else has trouble download the file (i.e. it's not found,) check the URL because it seems to be adding a comma to the end. Where did you get the source code for ls? I've been wondering where I could get that to play around with.
The color ls is actually the the ls from the GNU fileutils. Grab the source from one of many mirrors listed at:

I recommend installing the GNU Fileutils and Textutils. They are generally a little bit better than the BSD utilities.

Also, the correct place to put the color ls is not in /bin renamed to ls2. The correct place to put it would be in /usr/local/bin and have your path setup to search /usr/local/bin before /bin.
Your version of <tt>ls</tt> should be installed in /usr/local/bin, not /bin, and not /usr/bin.

Source for <tt>ls</tt> is available several places, depending what flavor you prefer. I'd recommend getting gnu fileutils and textutils and building everything there. <tt>make install</tt> will put all the gnu utils in /usr/local/bin where it can live safely away from the stock MacOS X <tt>ls</tt>. BSD <tt>ls</tt> should work too, although the options are a little different.
If you want to see how it looks, here's a screen grab.
Green = executable (execute permission)
Blue = directory
Cyan = link
White = who knows
There are a few other colors, too.


  • color_ls.png
    22.2 KB · Views: 94
It's possible to customize the colors any way you wish. You can even configure ls to highlight files of a certain type.

Make a configuration file in your home dir. Give it a name like <tt>.dircolors</tt> or something to identify it. What follows below is an example config:


# term entries, pick one, comment the other.
TERM vt100
#TERM xterm


# and then the colors codes... attribute codes are:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# color codes are
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white

NORMAL 00 # global default, although everything should be something.
FILE 00 # normal file
DIR 00;32 # directory
LINK 01;36 # symbolic link
FIFO 40;33 # pipe
SOCK 01;35 # socket
BLK 40;33;01 # block device driver
CHR 40;33;01 # character device driver

# This is for files with execute permission:
EXEC 01;33

# List any file extensions like '.gz' or '.tar' that you would like ls
# to colorize below. Insert the extension, a space,
# and the color init string.

*~ 05;31 # stuff we hate to find laying around (flashing red)
.c 00;35 # source code
.cpp 00;35
.h 00;36
.rb 00;35
.py 00;35
.pl 00;35
.cgi 00;35
.html 04;35
.tar 00;31 # archives or compressed (bright red)
.sit 00;31
.hqx 00;31
.dmg 00;31
.tgz 00;31
.gz 00;31
.arj 00;31
.rar 00;31
.Z 00;31
.zip 00;31

# end of file
<p>Now that you have a dircolors config, you need to add a
few lines to your the appropriate script for whatever shell
you use. Add this to your tcsh startup script or your
</tt>.bash_profile</tt>. Whenever you open a Terminal,
you need to run the <tt>dircolors</tt> command with the
config file above-- it's best to have your shell automatically
do this.

<pre>eval `dircolors ~/.dircolors`
alias ls='ls --color=always'