Changing the colors in Terminal ZSH on Mac OS

Quick way to change Terminal forground colors in zsh

Changing the colors in Terminal ZSH on Mac OS
Page content

Changing colors in Terminal

I utilize Command Line Interfaces (CLI) frequently, Linux, Unix, Mac etc. Small adjustments to the CLI can make huge impacts on my workflow. Readability of the screen is very important, and I personally prefer a slightly higher contrast display. What I mean by that is on a bright background I prefer dark foreground colors, and on a dark background I prefer bright foreground colors. Unfortuantly the out of the box configuration does not always allow that. For example on a what background the bright green executables can be hard to read, and on a black background the dark blue directory colors can be very hard to read. Below is the steps to adjust these colors on Mac Terminal which now defaults to zsh.

Source of Information: https://www.cyberciti.biz/faq/apple-mac-osx-terminal-color-ls-output-option/

Default Display

On Terminal you can select whichever background color you want. This is an example of out of the box “Pro” (black). As you can see cleary there are no colors displayed within the CLI.

image

Enable Color

To enable colors first set CLICOLOR=1

# Enable colors
export CLICOLOR=1

image

This is a perfect example, dark blue on black. If your in a dark room with no windows it should be reasonably easy to read. If you go outside in bright sunlight it will be nearly impossible read.

Change Dark Blue to Cyan

export LSCOLORS=gxfxcxdxbxegedabagacad

image

As you can see, with a readability has vastly increased simply by changing the forground directory color from dark blue to cyan. The color settings are below.

How to make permanent

Create or edit the file ~/.zsh

export CLICOLOR=1
export LSCOLORS=gxfxcxdxbxegedabagacad

Color Settings

exfxcxdxbxegedabagacad

So for our example if you want to change the directory color from the default to cyan, simply change exfxcxdxbxegedabagacad to gxfxcxdxbxegedabagacad.

Attribute Foreground color Background color
directory e x
symbolic f x
socket c x
pipe d x
executable b x
block e g
character e d
executable a b
executable a g
directory a c
directory a d
Code Meaning (Color)
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