본문 바로가기
OS/Mac OSX

[Mac] Change Colors of ls Command

by llHoYall 2020. 9. 25.

I'm currently using iTerm2 and the latest zsh.

In the past, as I remember that if I want to change the color of the ls command, I should set in the LS_COLORS shell variables.

But when I tried to set it with my new Mac in this time, it was LSCOLORS.

Anyway, let's find out this.

Default Value

My Mac's default value was Gxfxcxdxbxegedabagacad.

Oh Jeez, What is this?!!

When I set it up before, it seems that I set it up with an explicit name and number, but now I get an error saying that only certain alphabets and numbers are available when I try it.

warn: LSCOLORS should use characters a-h instead of 0-9 (see the manual page)

Let's dig some more this.

Meaning of the Alphabet

Alphabet Description Alphabet Description
a black A bold black
b red B bold red
c green C bold green
d brown D bold brown
e blue E bold blue
f magenta F bold magenta
g cyan G bold cyan
h light grey H bold light grey
x default foreground or background  

Oh, the alphabet meant color!

※ The brown is sometimes used in yellow, and the light grey is sometimes used in white.
※ The bold is the same meaning of bright.

So, what color is it?

Meaning of the Order

Order Description
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

Wow, this is what the order meant.

The default value had 22 alphabets.

So, it consisted of the foreground color and background color of each order.

Analyze

Let's match it!!

Values Description Foreground Color Background Color
Gx directory bright cyan default background
fx symbolic link magenta default background
cx socket green default background
dx pipe yellow default background
bx executable red default background
eg block special blue cyan
ed character special blue yellow
ab executable with setuid bit set black red
ag executable with setgid bit set black cyan
ac directory writable to others, with sticky bit black green
ad directory writable to others, without sticky bit black yellow

Now, it's easy to understand, right?

Then change the colors as you want.

 

In the previous, I set the color for specific file extension like "*.sh".

But I don't know how to set it without third party tool now. TwT

'OS > Mac OSX' 카테고리의 다른 글

[Mac] Configuration for Development  (0) 2020.09.26
[Mac] Shell Configuration (feat. zsh)  (0) 2020.09.25
[Mac] Terminal Configuration with iTerm2  (0) 2020.09.24
[Mac] Homebrew  (0) 2020.09.23
[Mac] Cheatsheet  (0) 2020.09.22

댓글