linux - ls 输出特定文件的颜色?

标签 linux git ls

是否可以为特定文件分配 ls 命令的输出颜色?
我问的原因是对于 git 存储库,我希望我跟踪的文件与未跟踪的文件具有不同的颜色。所以具体来说,我想获取“git ls-files”的输出并为这些文件赋予某种颜色(或将名称加粗或其他)。

最佳答案

对于标准的 ls 命令,这很容易。假设您想以紫色显示所有 .mp3 文件,然后运行:

$ LS_COLORS=$LS_COLORS:"*mp3=35:"

另外,请确保您的 ls 命令启用了 --color 选项。我通常使用类似的东西:
alias ls='ls --color=auto'

紫色是“35”。其他基本颜色是:
0   = default colour
1   = bold
4   = underlined
5   = flashing text
7   = reverse field
40  = black background
41  = red background
42  = green background
43  = orange background
44  = blue background
45  = purple background
46  = cyan background
47  = grey background
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

关于linux - ls 输出特定文件的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29351636/

相关文章:

Linux - 列出所有子目录并获取 ACL

javascript - 你的 gnome-shell-extension 如何捕获关键焦点?

linux - 使用新文件名从多个目录复制多个文件

linux - Linux 下键盘事件处理的内部工作原理

c++ - 如何在 VIM (gvim) 中启用智能感知

Git pull - 删除的文件

node.js - 从 docker 容器内发布 NPM 包

Python 子进程 Popen : Why does "ls *.txt" not work?

git - 使用 git add 添加除一个目录外的所有文件

amazon-s3 - 在aws cli中的ls返回 "PRE"。为什么以及如何摆脱它