By Manny Fernandez

January 9, 2020

Adding Color to Your macOS “ls” Output

Adding Color to Your macOS “ls” Output

I am big on having colors on my cli.  It makes things very easy to identify when things are amiss.  I have this on my SecureCRT implementation.  Here is an easy way to show colors on your ls output on your macOS.

Before

Here is the default way iTerm2 displays the output.

2020-01-09_12-40-00.png

Command to Change

Shell out to your terminal.

vi ~/.bashrc

Once you edit the file, hit i to enter the edit mode.

​add alias ls="ls -G"

2020-01-09_12-47-28.png

After

As you can see below, the blue text is very difficult to read against my dark background.

2020-01-09_12-46-55.png

Customization

Since that Dark Blue is unacceptable for my use, here is how to customize it.

For this, I will edit the

vi ~/.bash_profile

In there we will enter

export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced

2020-01-09_13-23-49.png

The color designators are as follows:

a black
b red
c green
d brown
e blue
f magenta
g cyan
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:

1. directory
2. symbolic link
3. socket
4. pipe
5. executable
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 bit

In my example, value LSCOLORS=GxFxCxDxBxegedabagaced, means directory = Gx (1st Position) set to (bold cyan foreground and default background). So Capital G = Bold Cyan and lowercase x = the default background

Outcome

2020-01-09_13-34-15.png

So on this output, I moved to my Desktop folder so we could see some files and some fake executable files.

  1. Directory colors are Cyan in bold
  2. We see standard files shown in white
  3. Files with the x attribute are shown in red.

Hope this helps

 

The vi Cheat Sheet (2026 Edition): From Survival Keys to Power Moves

The vi Cheat Sheet (2026 Edition): From Survival Keys to Power Moves

Use this vi cheat sheet to master survival keys and power moves. Learn vi modes, operator grammar, and vim extensions for fast config editing.

Read More
grep vs. egrep vs. fgrep: One Engine, Three Personalities

grep vs. egrep vs. fgrep: One Engine, Three Personalities

Learn the difference between grep, egrep, and fgrep. Fix legacy scripts, handle deprecation warnings, and choose the right mode for fast log analysis.

Read More
Monkey Bites – Auto Move Shortcut for macOS

Monkey Bites – Auto Move Shortcut for macOS

Create a macOS Shortcut to auto move files from your Downloads folder into organized subfolders based on file extension. Includes automation setup.

Read More