Add Color to the Terminal in Mac OS X
Adding colorized ls output to the Terminal in Mac OS X is a good way to make navigating around the command line a bit easier on the eyes. This makes different items show up in different colors, including directories, files, executables, and symbolic links.
We’ll cover a customizable color output setting for both dark and light terminals, and you can get a preview of color ls output by typing “ls -G” at the command line. The preview with ls -G will depend on the Terminals color settings and won’t necessarily represent the colors shown in the screenshots below, however.
- Open Terminal and type:
- Use the arrow keys to navigate to the bottom of the document and paste in either of the blocks of text below, depending on the terminals appearance (see man entry below for further customizations)
Colors for Dark Terminal Themes:
Colors for Light Terminal Themes:
- After the strings are pasted into .bash_profile confirm that it looks something like this in nano:
- Hit Control+O to save and open a new Terminal window
- Type "ls" or "ls -la" to confirm the colorized output
Optionally, you may want to create an alias in .bash_profile to link ls to something like ls -GFh, this would look like:
alias ls='ls -GFh'
This will work with Mac OS X 10.6, OS X 10.7, OS X 10.8, and beyond, as long as you are using the bash shell. If you aren't certain what shell you are using, look in the Terminal window titlebar for "bash", or you can check with the following command:
The output will be "/bin/bash" if it's bash, and something else if not.
Customizing LSCOLORS Manually
If the above color choices weren't doing it for you, you can set whatever you want. Here's the manual page on LSCOLORS if you want to give it a shot. The default is "exfxcxdxbxegedabagacad" but clearing out the .bash_profile color entry will remove any hideous color combinations too.
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
The color designators are as follows:
h light grey
A bold black, usually shows up as dark grey
B bold red
C bold green
D bold brown, usually shows up as yellow
E bold blue
F bold magenta
G bold cyan
H bold light grey; looks like bright white
x default foreground or background
Note that the above are standard ANSI colors. The actual
display may differ depending on the color capabilities of
the terminal in use.
The order of the attributes are as follows:
2. symbolic link
6. block special
7. character special
8. executable with setuid bit set
9. executable with setgid bit set
10. directory writable to others, with sticky bit
11. directory writable to others, without sticky
The default is "exfxcxdxbxegedabagacad", i.e. blue fore-
ground and default background for regular directories,
black foreground and red background for setuid executa-