{singhi}
🏷 tech
Mac/Linux系统Terminal中不同文件类型的颜色
🌙 💬 📅
ex fx cx
directory symbolic link socket
dx bx  
pipe executable  
eg ed ab
block special character special executable with setuid bit set
ag ac ad
executable without setuid / black / cyan directory with sticky / black / green directory without sticky / black / brown

Now, let’s learn how we can configure our Terminal to obtain the colors of the figure.

Terminal custom colors
Terminal custom colors

Colors can be changed using the LSCOLORSvariable in the ~/.zsh_profile. By default is set to

LSCOLORS=exfxcxdxbxegedabagacad

where the string exfxcxdxbxegedabagacad is a concatenation of pairs of the format TB, where T is the text color and B is the Background color.

The order of these pairs correspond to:

  1. directory
  2. symbolic link – special kind of file that contains a reference to another file or directory.
  3. socket – special kind of file used for inter-process communication.
  4. pipe – special file that connects the output of one process to the input of another.
  5. executable
  6. block special – a kind of device file.
  7. character special – a kind of device file.
  8. executable with setuid bit set (setuid is a short for set user ID upon execution).
  9. executable with setgid bit set (setgid is a short for set group ID upon execution).
  10. directory writable to others, with sticky bit – only the owner can rename or delete files.
  11. directory writable to others, without sticky bit – any user with write and execution permissions can rename or delete files.

And the different letters correspond to:

  • a black
  • b red
  • c green
  • brown
  • blue
  • f magenta
  • g cyan
  • h light grey
  • x default color

The same letters in uppercase indicate Bold.

The Terminal default colors, described by exfxcxdxbxegedabagacad, and ordered by file type / text color / background color, are:

  1. ex –> directory / blue / default
  2. fx –> symbolic link / magenta / default
  3. cx –> socket / green / default
  4. dx –> pipe / brown / default
  5. bx –> executable / red / default
  6. eg –> block special / blue / cyan
  7. ed –> character special / blue / brown
  8. ab –> executable with setuid / black / red
  9. ag –> executable without setuid / black / cyan
  10. ac –> directory with sticky / black / green
  11. ad –> directory without sticky / black / brown

You can change the colors of your terminal by creating a new concatenated string, like
GxFxCxDxBxegedabagaced, and writing in the .bash_profile file the following line:

export LSCOLORS=GxFxCxDxBxegedabagaced

Enjoy the new Terminal layout!