`
willzh
  • 浏览: 300783 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

COLORS-Lscolors

阅读更多

<!----> 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

search Search Index

分享到:
评论

相关推荐

    前端开源库-colors-browserify

    【颜色浏览器化库-colors-browserify详解】 在前端开发中,色彩处理是不可或缺的一部分,而`colors-browserify`就是一款专为浏览器环境设计的颜色处理库。这个开源项目旨在为前端开发者提供一个简单、易用的工具,...

    vim-colors-solarized, vim文本编辑器的精确 colorscheme.zip

    vim-colors-solarized, vim文本编辑器的精确 colorscheme 标题描述作者创建的颜色已经修改用于Vim的Solarized colorscheme机器和人员的精确颜色Schoonover浅黄色2011 152011年 16用于Vim的 Solarized colorsche

    PyPI 官网下载 | colors-boss_space-0.0.3.tar.gz

    《PyPI官网下载 | colors-boss_space-0.0.3.tar.gz——探索Python云原生分布式编程》 在IT领域,Python作为一种简洁且强大的编程语言,被广泛应用于各种项目中,尤其是对于云原生(Cloud Native)环境的开发。在...

    开源项目-husl-colors-husl-go.zip

    开源项目“husl-colors-husl-go.zip”聚焦于HUSL色彩空间的Go语言实现,名为“husl-go”。HUSL是一种基于HSL(色相、饱和度、亮度)颜色模型的改进版本,旨在更好地匹配人类视觉感知的颜色差异。在软件开发中,特别...

    solarized.zip

    emacs-colors-solarized gimp-palette-solarized intellij-colors-solarized iterm2-colors-solarized misc-apps mutt-colors-solarized netbeans-colors-solarized osx-terminal.app-colors-solarized palettes ...

    PyPI 官网下载 | fau_colors-0.2.0-py3-none-any.whl

    《PyPI官网下载:深入解析fau_colors-0.2.0-py3-none-any.whl》 在Python的世界里,PyPI(Python Package Index)是开发者们分享和获取Python软件包的重要平台。"fau_colors-0.2.0-py3-none-any.whl"便是这样一个从...

    开源项目-reconquest-loreley#colors-in-texttabwriter.zip

    开源项目-reconquest-loreley#colors-in-texttabwriter.zip,How to use colors in text/tabwriter tables

    Colors-01.rar

    本资源“Colors-01.rar”似乎聚焦于如何在Qt环境下利用OpenGL处理颜色相关的编程问题。在本文中,我们将深入探讨颜色在OpenGL中的表示方式以及如何在Qt应用中有效地利用OpenGL进行颜色操作。 首先,我们来理解颜色...

    vim-colors-pencil, 基于iA的光( &暗色) 配色方案.zip

    vim-colors-pencil, 基于iA的光( &暗色) 配色方案 vim-colors-pencil一种基于iA的光照( 深色) 配色方案 特性铅笔配色方案来自iA编写器,这是iOS和OSX平台上提供的优雅文字处理器。这里Vim配色方案功能:gutter变化的...

    Atom-atom-humble-colors-syntax,Atom的语法主题,外观简洁明了。.zip

    "Atom-atom-humble-colors-syntax.zip" 文件是一个专门为Atom设计的语法主题,名为"Humble Colors Syntax"。 语法主题是编辑器中的一个重要组成部分,它决定了代码在编辑器中的颜色显示方式。"Humble Colors Syntax...

Global site tag (gtag.js) - Google Analytics