LS_COLORS的妙用
来源:互联网 发布:编程语言是什么样 编辑:程序博客网 时间:2024/06/02 18:33
【转】LS_COLORS的妙用
COLORS-Lscolors
From:
Here is an easy way to set different colours for different kinds of files when using the ls command.
Add the following lines to the bottom of your ~/.bashrc file -
alias ls='ls --color'
LS_COLORS='di=1:fi=0:ln=31:pi=5:so=5:bd=5:cd=5:or=31:mi=0:ex=35:*.rpm=90'
export LS_COLORS
The first line makes ls use the --color parameter by default, which tells ls to display files in different colours based on the setting of the LS_COLORS variable.
The second line is the tricky one, and what I have worked out so far has been by trial and error. The parameters (di, fi, etc.) refer to different Linux file types. I have worked them out as shown
di = directory
fi = file
ln = symbolic link
pi = fifo file
so = socket file
bd = block (buffered) special file
cd = character (unbuffered) special file
or = symbolic link pointing to a non-existent file (orphan)
mi = non-existent file pointed to by a symbolic link (visible when you type ls -l)
ex = file which is executable (ie. has 'x' set in permissions).
The *.rpm=90 parameter at the end tells ls to display any files ending in .rpm in the specified colour, in this case colour 90 (dark grey). This can be applied to any types of files (eg. you could use '*.png=35' to make jpeg files appear purple.) As many or as few parameters as you like can go into the LS_COLORS variable, as long as the parameters are separated by colons.
Using trial and error (and a little bash script I wrote... my first one ever! :) I worked out all the colour codes, at least my interpretation of them -
0 = default colour
1 = bold
4 = underlined
5 = flashing text
7 = reverse field
31 = red
32 = green
33 = orange
34 = blue
35 = purple
36 = cyan
37 = grey
40 = black background
41 = red background
42 = green background
43 = orange background
44 = blue background
45 = purple background
46 = cyan background
47 = grey background
90 = dark grey
91 = light red
92 = light green
93 = yellow
94 = light blue
95 = light purple
96 = turquoise
100 = dark grey background
101 = light red background
102 = light green background
103 = yellow background
104 = light blue background
105 = light purple background
106 = turquoise background
These can even be combined, so that a parameter like:
di=5;31;42
in your LS_COLORS variable would make directories appear in flashing red text with a green background!
Setting LS_COLORS does more than just make your ls listings look pretty (although it certainly does do that), it is also very helpful in identifying files while wading through a file system.
LS_COLORS='no=00:fi=00:di=01;33:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32
:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;3
1:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm
=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:'
这个是我的系统里经常用的颜色配置,还不错
- LS_COLORS的妙用
- /()/的妙用
- ${}的妙用
- Rpm软件包管理工具的妙用妙用
- exception的妙用
- Google的妙用
- 删除文件的妙用
- Response.Buffer的妙用
- 尿的妙用
- PING的妙用
- template的妙用
- 替换的妙用
- sp_executesql的妙用
- 智能ABC的妙用
- JESS专家系统的妙用
- 特殊字体的妙用
- getusername的企业妙用
- 谈TEAXAREA的妙用
- 排序
- 17周 项目2.3 求字符串的长度 并返回 用指针做形参
- opencv学习-训练harr特征分类器
- ORA-02283: 无法变更启动序列号
- paip.c3p0 数据库连接池 NullPointerException 的解决...
- LS_COLORS的妙用
- js刷新页面方法大全
- 浅谈Java中的Set、List、Map的区别
- 在MFC中添加用户自定义消息
- iOS UINavigationController + UITabBarController
- 2013-12-18 17:38:40
- uestc 1901 方方是个坏孩子
- iphone中结束电话后返回自己的应用
- itye 地址