ls コマンド の結果に色を設定する

mac, fish の場合を記載します

環境変数 LSCOLORS を設定します

set -x LSCOLORS exfxcxdxbxegedabagacad

設定値は 22桁あり
文字色, 背景色 の 2桁ずつが組となって, 11の設定箇所を表しています

11の設定箇所は次です

01: directory
02: symbolic link
03: socket
04: pipe
05: executable
06: block special
07: character special
08: executable with setuid bit set
09: executable with setgid bit set
10: directory writable to others, with sticky bit
11: directory writable to others, without sticky bit

設置値と色の対応は次です

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

ls コマンドに色をつけて出力するには -G オプションをつけます

ls -G