[root@www ~]# man -K LS_COLORS
/usr/share/man/overrides/man1/lftp.1.gz? [ynq] y
-----------------------------------------------------------------------------------------------------------------------------------------------

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.

002_让你的linux虚拟终端五彩缤纷(1)——LS颜色设置的更多相关文章

  1. linux终端界面的字颜色设置

    目录 目录 说明 PS1 颜色语法 保存设置 说明 在网上找了好多资料都不是很详细,要不就是语法有错误. 所以弄了好久才整明白了,写下来方便后面的人学习. 本人linux虚拟机版本为CentOs 6. ...

  2. Linux中文显示乱码?如何设置centos显示中文

    Linux中文显示乱码?如何设置centos显示中文 怎么设置Linux系统中文语言,这是很多小伙伴在开始使用Linux的时候,都会遇到一个问题,就是终端输入命令回显的时候中文显示乱码.出现这个情况一 ...

  3. 更改linux文件夹的默认颜色

    我不知道正常人看Linux下面文件夹的颜色(默认为深蓝)是不是有点晕晕的,看不清楚,反正对我这样的色弱的人来说,我看着很不爽,所以我到网上去找了一下,如果修改文件夹颜色的方法,网上真实众说纷纭,很多都 ...

  4. Linux修改Shell命令提示符及颜色

    Linux修改Shell命令提示符及颜色 1. Linux登录过程中加载配置文件顺序: /etc/profile → /etc/profile.d/*.sh → ~/.bash_profile → ~ ...

  5. hadoop搭建杂记:Linux下JDK环境变量的设置(三种配置环境变量的方法)

    Linux下JDK环境变量的设置(三种配置环境变量的方法) Linux下JDK环境变量的设置(三种配置环境变量的方法) ①修改/etc/profile文件 如果你的计算机仅仅作为开发使用时推荐使用这种 ...

  6. Linux centos 主机名颜色设置 和 别名设置

    方便和乐趣写今天.至于为什么主机名颜色设置 和 别名设置放在一起写.这是因为他们的设置是在一个文件中..bashrc. .bashrc放在cd /root 这个文件夹下! 这个文件主要保存个人的一些个 ...

  7. c/c++ linux epoll系列3 利用epoll_wait设置timeout时间长度

    linux epoll系列3 利用epoll_wait设置timeout时间长度 epoll_wait函数的第四个参数可以设置,epoll_wait函数的等待时间(timeout时间长度). 例子1, ...

  8. Linux 调试打印时间和颜色

    Linux调试打印时间和颜色 #include <sys/time.h> #include <unistd.h> void print_time(void) { struct ...

  9. Linux Linux下最大文件描述符设置

    Linux下最大文件描述符设置 by:授客 QQ:1033553122 1.   系统可打开最大文件描述符设置 查看系统可打开最大文件描述符 # cat /proc/sys/fs/file-max 6 ...

随机推荐

  1. 拓展kmp总结

    借鉴自:https://blog.csdn.net/dyx404514/article/details/41831947 定义母串S,和子串T,设S的长度为n,T的长度为m,求T与S的每一个后缀的最长 ...

  2. SpringBoot多数据源配置事务

    除了消费降级,这将会是娱乐继续下沉的一年. 36氪从多个信源处获悉,资讯阅读应用趣头条已经完成了腾讯领投的Pre-IPO轮融资,交易金额预计达上亿美元,本轮融资估值在13-15亿美金之间:完成此轮融资 ...

  3. 常州day1p3

    给定一个 n 行 m 列的方格,每个格子里有一个正整数 a,1 ≤ a ≤ k,k ≤ n∗m 假设你当前时刻站在 (i,j) 这个格子里,你想要移动到 (x,y),那必须满足以下三个条件 1:i & ...

  4. Asp.Net保存session的三种方法 (Dll文件更新导致session丢失的解决办法)

    1. InProc模式(默认值):asp.net将session保存到当前进程中,这种方式最快,但是不能多台服务器共享session,且会话状态数据容易丢失. <sessionState mod ...

  5. https的通信过程

    https的特点 1. https有 握手阶段 和 请求阶段2. 握手阶段 使用 非对称加密算法 请求阶段 使用 对称加密算法3. 保证数据的完整性使用数字签名4. 握手阶段有两组非对称加密,数字证书 ...

  6. 【CodeChef】ForbiddenSum

    Portal --> CC ForbiddenSum Solution 场上想到了\(O(NM)\)的做法..然而并没有什么用 首先考虑比较简单的一个问题,给定一个数组\(A\),问这些数不能凑 ...

  7. Java之基础20160806

    注意这里介绍的JAVA基础是指你对C语言已经比较熟练或者有一定基础了,再学习如下这知识就会比较快. 1.JAVA也是从MAIN开始执行,但是要先定义类,文件名要与类名一致并且类名首字母要大写,同时JA ...

  8. omnet++4.0安装使用

    http://my.oschina.net/u/2269841/blog/423659 本文主要借鉴该文章在此对作者表示由衷的感谢http://blog.csdn.net/xiaobei4929/ar ...

  9. Qt实现截屏并保存(转载)

    原博地址:http://blog.csdn.net/qinchunwuhui/article/details/52869451?_t_t_t=0.28889142944202306 目前对应用实现截屏 ...

  10. 新式类 VS 经典类

    一.概述 Python中支持多继承,也就是一个子类可以继承多个父类/基类.当一个调用一个自身没有定义的属性时,它是按照何种顺序去父类中寻找的呢?尤其是当众多父类中都包含有同名的属性,这就涉及到新式类 ...