怎样改变Linux控制台中目录的显示颜色

有的时候Linux控制台显示的目录颜色与背景颜色反差不大,看不清楚,可以使用LS_COLORS来改变目录的颜色。

LS_COLORS=$LS_COLORS:'di=0;35:'

LS_COLORS,顾名思义,设置的是 ls显示的颜色。
di表示是 directory.
不同项的颜色设置用:分隔,同一项的颜色设置用;分隔。
比如上例中的di=0;350表示样式是默认的,35表示颜色是紫色。
紫色目录
可选样式:

数字样式
0default color
1bold
4underlined
5flashing text (disabled on some terminals)
7reverse field (exchange foreground and background color)
8concealed (invisible)

可选颜色:

数字颜色
31Red
32Green
33Orange
34Blue
35Purple
36Cyan(青色)
37Grey
90Dark grey
91Light red
92Light green
93Yellow
94Light blue
95Light purple
96Turquoise
97White

可选背景颜色:

数字颜色
40Black background
41Red background
42Green background
43Orange background
44Blue background
45Purple background
46Cyan background
47Grey background
100Dark grey background
101Light red background
102Light green background
103Yellow background
104Light blue background
105Light purple background
106Turquoise background(蓝绿色背景)

假如想要把目录颜色设为带下划线的浅红色,背景为蓝绿色,则设为:

export LS_COLORS=$LS_COLORS:"di=04;91;106:"

蓝绿色目录
扩展
假如想设置除di之外的其他颜色,请参考下表的关键字。

Key/etc/DIR_COLORS nameNotes
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, BLKdevice
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_WRITABLEDirectory that 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
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值