- 论坛徽章:
- 0
|
Linux下,文件的字体颜色是黑色,目录的颜色是绿色。。。然而是哪个文件控制着这些字体的颜色,怎样更改他们呢?
/etc/DIR_COLORS就是控制文件字体颜色的配置文件,他是系统默认颜色的配置文件,当我们需要更改显示颜色时,需要以用户为对象来更改,就是说每一个用户拥有一个颜色控制的配置文件,具体操作如下:
Cp –p /etc/DIR_COLORS ~/.dir_colors
再更改.dir_colors文件:
# Configuration file for the color ls utility
# This file goes in the /etc directory, and must be world readable.
# You can copy this file to .dir_colors in your $HOME directory to override
# the system defaults.
# COLOR needs one of these arguments: 'tty' colorizes output to ttys, but not
# pipes. 'all' adds color characters to all output. 'none' shuts colorization
# off.
COLOR tty
# Extra command line options for ls go here.
# Basically these ones are:
# -F = show '/' for dirs, '*' for executables, etc.
# -T 0 = don't trust tab spacing when formatting ls output.
OPTIONS -F -T 0
# Below, there should be one TERM entry for each termtype that is colorizable
TERM linux
TERM console
TERM con132x25
TERM con132x30
TERM con132x43
TERM con132x60
TERM con80x25
TERM con80x28
TERM con80x30
TERM con80x43
TERM con80x50
TERM con80x60
TERM cons25
TERM xterm
TERM rxvt
TERM xterm-color
TERM color-xterm
TERM vt100
TERM dtterm
TERM color_xterm
TERM ansi
TERM screen
TERM screen.linux
TERM kon
TERM kterm
TERM gnome
TERM konsole
# EIGHTBIT, followed by '1' for on, '0' for off. (8-bit output)
EIGHTBIT 1
# 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
NORMAL 00 # global default, although everything should be something.
FILE 00 # normal file
DIR 01:34 ---只能在此基础上修改,不能再加一项,例如01:34:43,这样是不行的,显示会出错,而这样的错误需要重启系统才能更正, # directory
LINK 01:36 # symbolic link
FIFO 40:33 # pipe
SOCK 01:35 # socket
BLK 40:33:01 # block device driver
CHR 40:33;01 # character device driver
ORPHAN 01:05:37:41 # orphaned syminks
MISSING 01:05:37:41 # ... and the files they point to
# This is for files with execute permission:
EXEC 01;32
# List any file extensions like '.gz' or '.tar' that you would like ls
# to colorize below. Put the extension, a space, and the color init string.
# (and any comments you want to add after a '#')
.cmd 01;32 # executables (bright green)
.exe 01;32
.com 01;32
.btm 01;32
.bat 01;32
.sh 01;32
.csh 01;32
.tar 01;31 # archives or compressed (bright red)
.tgz 01;31
.arj 01;31
.taz 01;31
.lzh 01;31
.zip 01;31
.z 01;31
.Z 01;31
.gz 01;31
.bz2 01;31
.bz 01;31
.tz 01;31
.rpm 01;31
.cpio 01;31
.jpg 01;35 # image formats
.gif 01;35
.bmp 01;35
.xbm 01;35
.xpm 01;35
.png 01;35
.tif 01;35
根据颜色的代码,将各类文件标示以不同的代码,注销(没必要重启)用户再登录即可,如果需要其他用户也运用这些颜色,将该文件copy到宿主目录下即可。
当然:如果你想所有用户共用一种颜色设置,那就直接修改/etc/DIR_COLORS.xtermj即可全局作用,不用逐个用户copy
如果在叙述中有错误,希望大家多多指教。本人还有很多原创的东西,希望能和大家一起分享和讨论,学习。 |
|