免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 7182 | 回复: 5
打印 上一主题 下一主题

原创:linux文件字体颜色 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-01-21 21:20 |只看该作者 |倒序浏览
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
如果在叙述中有错误,希望大家多多指教。本人还有很多原创的东西,希望能和大家一起分享和讨论,学习。

论坛徽章:
0
2 [报告]
发表于 2010-01-22 14:51 |只看该作者
我的ubuntu系统没有找到这个文件。
你是什么系统?

论坛徽章:
0
3 [报告]
发表于 2010-01-22 14:55 |只看该作者
我的是centos5,Ubuntu里面没有试过

论坛徽章:
0
4 [报告]
发表于 2010-01-22 15:06 |只看该作者
redhat有。。。

论坛徽章:
0
5 [报告]
发表于 2010-01-22 16:11 |只看该作者
刚尝试了下  确实不错   3Q

论坛徽章:
0
6 [报告]
发表于 2011-03-18 10:37 |只看该作者
只能在此基础上修改,不能再加一项,例如01:34:43,这样是不行的,显示会出错,
那么下面这些值是用在哪里的?
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP