Linux ls 颜色设置
来源:互联网 发布:什么是大数据应用 编辑:程序博客网 时间:2024/04/29 03:55
Here is an easy way to set different colours for different kinds of files when using thels 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 theLS_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 theLS_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.
- Linux ls 颜色设置
- debian linux下ls的颜色设置
- linux ls文件颜色和底色设置
- Linux ls 文件名颜色
- linux 下设置 ls 命令 显示 文件、文件夹颜色
- [linux_shell]linux下设置ls命令显示文件、文件夹颜色
- Linux设置ls时不同类型文件的颜色
- linux设置ls显示的各种文件颜色
- shell ls的颜色设置
- linux修改ls文件颜色
- 配置linux颜色的一些技巧 +man颜色+ ls颜色
- linux ubuntu ls之颜色管理
- Linux下ls命令颜色效果
- dircolors配置,linux目录颜色配置ls
- 设置ls输出的颜色 设置vi中comment的颜色
- Linux ls文件夹颜色(蓝色)的改变方法
- Linux下ls显示文件颜色的含义
- linux ls命令不显示文件颜色的解决
- xml parse
- 药物作用靶点逐个数
- uva445
- WebAPP 开发tips for iPad
- NYOJ-524 A-B Problem【高精度】
- Linux ls 颜色设置
- 【转】event.cancelBubble与event.stopPropagation()
- 驱动返回值代码查询
- Google美女副总裁梅伊尔给年轻女性的5条建议(对男士也有用)
- SaaS
- mydiv(int a,int b,int c[10])
- linux下shell中if的相关参数以及$位置参数的数量
- 介绍iPad设备UI的长宽高
- 关于delegate的形象理解