终端下更改文件显示颜色

本博文为原创,遵循CC3.0协议,转载请注明出处:http://blog.csdn.net/lux_veritas/article/details/9121221

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


终端下开启ansi标准颜色显示,可以通过以下方式手动更改目录、普通文件等的显示颜色

/etc/DIR_COLORS文件详尽描述了终端下的文件颜色设置,

# Below are the color init strings for the basic file types. A color init                                                                                    
# string consists of one or more of the following numeric codes:                                                                                             
# Attribute codes:                                                                                                                                           
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed                                                                                             
# Text color codes:                                                                                                                                          
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white                                                                                     
# Background color codes:                                                                                                                                    
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white 


按注释所述,选择替换的颜色后,保存文件。(系统默认/etc/DIR_COLORS文件为只读,确保先获得写权限)

eval `dircolors /etc/DIR_COLORS`


执行以上命令,使新设置的颜色生效。

原文地址:https://www.cnblogs.com/snake-hand/p/3142959.html