linux terminal 目录的背景色

问题

/ls_color/example.png
背景色
平时用terminal的时候,偶尔会遇到这种有背景色的目录,这是因为该路径除了所有者外,还有其他人有权限。在有背景色的情况下,很容易与主题色发生冲突,导致看不清路径名称。修改方案除了调整路径的权限外,还有修改LS_COLORS环境变量。

1
2
$ echo $LS_COLORS
di=1;36:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43

LS_COLORS环境变量由多个键值对用冒号连接而成,每个键值对的结构为key=val1;val2,不同值之间用分号连接。其中key为文件的类型缩写,value为对应的颜色编码

key值表

keydir_colors namedescription
noNORMAL, NORMGlobal default, although everything should be something
fiFILENormal file
diDIRDirectory
lnSYMLINK, LINK, LNKSymbolic link. If you set this to ’target’ instead of a numerical value, the colour is as for the file pointed to.
piFIFO, PIPENamed pipe
doDOORDoor
bdBLOCK, BLKBlock device
cdCHAR, CHRCharacter device
orORPHANSymbolic link pointing to a non-existent file
soSOCKSocket
suSETUIDFile that is setuid (u+s)
sgSETGIDFile that is setgid (g+s)
twSTICKY_OTHER_WRITABLEDirectory that is sticky and other-writable (+t,o+w)
owOTHER_WRITABLE Directorythat is other-writable (o+w) and not sticky
stSTICKYDirectory with the sticky bit set (+t) and not other-writable
exEXECExecutable file (i.e. has ‘x’ set in permissions)
miMISSINGNon-existent file pointed to by a symbolic link (visible when you type ls -l)
lcLEFTCODE, LEFTOpening terminal code
rcRIGHTCODE, RIGHTClosing terminal code
ecENDCODE, ENDNon-filename text
*.extensionEvery file using this extension e.g. *.jpg

value表

effects

codeproperty
00Default colour
01Bold
04Underlined
05Flashing text
07Reversetd
08Concealed

colors

codeproperty
30Black
31Red
32Green
33Orange
34Blue
35Purple
36Cyan
37Grey

backgrounds

codeproperty
40Black background
41Red background
42Green background
43Orange background
44Blue background
45Purple background
46Cyan background
47Grey background

extra colors

codeproperty
90Dark grey
91Light red
92Light green
93Yellow
94Light blue
95Light purple
96Turquoise
97White
100Dark grey background
101Light red background
102Light green background
103Yellow background
104Light blue background
105Light purple background
106Turquoise background
107White background

修改

1
export LS_COLORS=${LS_COLORS}'key=val1;val2':