[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. Debug快捷键

    Debug快捷键 1. F5单步调试进入函数内部2. F6单步调试不进入函数内部3. F7由函数内部返回到调用处4. F8一直执行到下一个断点5. F11 重新运行debug

  2. 聊聊flink的Async I/O

    // This example implements the asynchronous request and callback with Futures that have the // inter ...

  3. 基于 HTML5 的人脸识别技术

    基于 HTML5 的人脸识别技术 https://github.com/auduno/headtrackr/

  4. Alpha 冲刺 —— 十分之一

    队名 火箭少男100 组长博客 林燊大哥 作业博客 Alpha 冲鸭! 成员冲刺阶段情况 林燊(组长) 过去两天完成了哪些任务 协调各成员之间的工作,对多个目标检测及文字识别模型进行评估.实验,选取较 ...

  5. 「CodePlus 2017 12 月赛」可做题2(矩阵快速幂+exgcd+二分)

    昨天这题死活调不出来结果是一个地方没取模,凉凉. 首先有个一眼就能看出来的规律... 斐波那契数列满足$a_1, a_2, a_1+a_2, a_1+2a_2, 2a_1+3a_2, 3a_1+5a_ ...

  6. Amphetamine的cf日记

    之前挂上的 今天填坑 2018.2.14 #462 A 给两个集合,B分别可以从一个集合中选一个数,B想乘积最大,A想最小,A可以删除一个第一个集合中的元素,问最小能达到多少. 这题..水死啦.我居然 ...

  7. 【loj2472】IIIDX

    Portal --> loj2472 Solution 感觉是一道很有意思的贪心题啊ovo(想了一万个假做法系列==) 比较直观的想法是,既然一个数\(i\)只会对应一个\(\lfloor\fr ...

  8. python函数:字符串函数示例

    优先掌握的操作 #作用:名字,性别,国籍,地址等描述信息 #定义:在单引号\双引号\三引号内,由一串字符组成 name='egon' #优先掌握的操作: #1.按索引取值(正向取+反向取) :只能取 ...

  9. Linux之GDB调试介绍与应用20170601

    一.GDB调试命令   描述 backtrace(或bt) 查看各级函数调用及参数 finish 连续运行到当前函数返回为止,然后停下来等待命令 frame(或f) 帧编号 选择栈帧 info(或i) ...

  10. oracle中 trunc(),round(),ceil(),floor的使用

    oracle中 trunc(),round(),ceil(),floor的使用 原文: http://www.2cto.com/database/201310/248336.html 1.round函 ...