linux修改ls文件颜色

   ls指令显示的文件,可以通过设置环境变量LS_COLORS,修改不同类型文件显示的颜色。LS_COLORS可以通过指定文件设定,如:

shell terminal$dircolors -b .mydircolor

  若未指定,则读取默认的值,可以通过如下指令查看。

shell terminal$dircolors -p
   更多信息请通过 man dircolors(1)查看。

    自己定制ls输出的文件颜色时,可以通过多个方法定制:


在.bashrc、/etc/profile等初始化的文件中定义LS_COLORS:(e.g.)
LS_COLORS="ow=01;90:di=01;90"
export LS_COLORS
     2.

获取默认值写入一文件(.mydircolor)
shell terminal$dircolors -p > ~/.mydircolor
按照自己喜好修改文件~/.mydircolor
在.bashrc等初始化文件中加入语句:
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" 

       

   LS_COLORS值是key-value的字符串,key可取的值见下表:

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 color 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_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
*.extension Every file using this extension e.g. *.jpg


         每个key对应的value,确定该类文件的颜色,value可以由多个值以“;"分割开(字体颜色、背景颜色),各个key之间以":"分割开。value的可取值如下表:

                    

Effects
00Default colour
01Bold
04Underlined
05Flashing text
07Reversetd
08Concealed
Colours
31Red
32Green
33Orange
34Blue
35Purple
36Cyan
37Grey
Backgrounds
40Black background
41Red background
42Green background
43Orange background
44Blue background
45Purple background
46Cyan background
47Grey background
Extra colours
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

更多信息,参考:

http://www.bigsoft.co.uk/blog/index.php/2008/04/11/configuring-ls_colors

http://ubuntuforums.org/showthread.php?t=1297960

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值