是否可以为特定文件分配 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/