[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. 【BZOJ1951】古代猪文(CRT,卢卡斯定理)

    [BZOJ1951]古代猪文(CRT,卢卡斯定理) 题面 BZOJ 洛谷 题解 要求什么很显然吧... \[Ans=G^{\sum_{k|N}{C_N^k}}\] 给定的模数是一个质数,要求解的东西相 ...

  2. CODECHEF Chef and Churus 解题报告

    [CODECHEF]Chef and Churus Description 有一个长度为\(n\)的数组\(A\),有\(n\)个函数,第\(i\)个函数的值为\(\sum_{j=l_i}^{r_i} ...

  3. [CTSC2007]动物园zoo

    link 试题分析 发现每个小朋友最多只能看到$5$个动物所以考虑状压$dp$.我们定义$f(i,j)$为第$i$个位置从此往后$5$个人的最喜欢数量.所以只要预处理出对于每个点从后$5$个会让多少小 ...

  4. 洛谷P1012 拼数

    题目描述 设有n个正整数(n≤20),将它们联接成一排,组成一个最大的多位整数. 例如:n=3时,3个整数13,312,343联接成的最大整数为:34331213 又如:n=4时,4个整数7,13,4 ...

  5. mysql 给用户赋值权限

    解决办法 grant all privileges on *.* to joe@localhost identified by '1'; flush privileges; 拿 joe 1 登陆 附: ...

  6. Rabbitmq -- rpc

    一.前言 MQ本身是基于异步的消息处理,前面的示例中所有的生产者(P)将消息发送到RabbitMQ后不会知道消费者(C)处理成功或者失败(甚至连有没有消费者来处理这条消息都不知道).但实际的应用场景中 ...

  7. (转)MySQL建表设置两个默认CURRENT_TIMESTAMP的技巧

    业务场景: 例如用户表,我们需要建一个字段是创建时间, 一个字段是更新时间. 解决办法可以是指定插入时间,也可以使用数据库的默认时间. 在mysql中如果设置两个默认CURRENT_TIMESTAMP ...

  8. [DeeplearningAI笔记]序列模型2.8 GloVe词向量

    5.2自然语言处理 觉得有用的话,欢迎一起讨论相互学习~Follow Me 2.8 GloVe word vectors GloVe词向量 Pennington J, Socher R, Mannin ...

  9. 原生JS实现点击一个按钮显示一个div,再点击按钮div隐藏,或点击除div外其它空白处div隐藏

    <!DOCTYPE html> <html style="font-size: 24px"> <head> <title>js点击按 ...

  10. NOIP模拟赛8

    今天又爆零啦... T1 题目描述 #define goodcatdog gcd #define important i #define judge  j 神说 每个梦想就是一轮月亮,高高地孤寂地挂在 ...