<!---->
COLORS-Lscolors
From: Bartman
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.
If anyone finds out additional info on LS_COLORS
, or spots an error, please
e-mail me, I would like to know. Any questions may also be
directed to me by e-mail.
Bartman
分享到:
相关推荐
**ls-colors-zsh 插件详解** 在Unix和Linux操作系统中,命令行界面是日常操作的核心部分。`ls`命令用于列出目录内容,而`LS_COLORS`则是一个环境变量,它允许`ls`以不同的颜色显示不同类型的文件,使得终端输出更易...
`lscolors` 是一个基于 Rust 编写的库和命令行工具,它扩展了 Unix 类系统的 `ls` 命令,通过利用 `LS_COLORS` 环境变量来为终端中的文件和目录添加颜色,使得在终端中浏览文件系统更加直观和高效。`LS_COLORS` 是一...
ls-colors或lscolors是dircolors的别名,它们提供了自定义颜色方案的可能性,让文件管理变得更加直观。 要实现zsh中使用dircolors进行实时语法高亮,首先需要确保你已经在系统上安装了zsh和zsh-syntax-highlighting...
搜索存储库使用Github搜索界面–只需输入查询(例如“ trapd00r / LS_COLORS”)(如下图所示),以找到具有此插件引用的zshrc,并确保激活搜索的“在此存储库中”变体: 然后,结果应如下所示:或者 ... 只需克隆...
LS_COLORS 是一个在类 Unix 系统中,如 Linux 和 macOS,用来自定义 `ls` 命令显示颜色的环境变量。这个环境变量允许用户根据文件类型、权限和其他属性来指定不同的颜色,使得终端输出的目录内容更加易读和有组织。 ...
# Custom colors for bash Terminal in macOS # Default is: “exfxcxdxbxegedabagacad” export LSCOLORS=gxgxcxdxbxegedabagacad export CLICOLOR=1 # Custom colored bash prompt C0= " \e[38;5;120m\] " # ...