How can I configure Mac Terminal to have color ls output?

How can I configure Mac Terminal to have color ls output? I am using MacOS 10.5


Edit:

~/.bash_profile

or

~/.profile

and add the following line to simply enable color output via ls:

export CLICOLOR=1

To customize the coloring shown by ls you can optionally add this variable, LSCOLORS.

Examples

  • Default

    export LSCOLORS=ExFxCxDxBxegedabagacad
    
  • You can use this if you are using a black background

    export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx
    
  • If you'd like to mimic the colors of a typical Linux terminal:

    export LSCOLORS=ExGxBxDxCxEgEdxbxgxcxd
    

Once you've add the above to either ~/.bash_profile or ~/.profile you can either logout/login or source the file in your shell, for eg:

$ . ~/.bash_profile

NOTE: If you need help in selecting colors to use you can use this online tool called LSCOLORS Generator.


You can add

alias ls='ls -G'

to your ~/.bash_profile to get colored ls output.