在控制臺下,用ls,就會發現,shell將不同類型的文件項目顯示為不同的顏色。者可以提高效率,不用ls -l便能大概的把各個文件的類型情況了解一下。
你有沒有想過更改這個著色配置呢?
其 實,在/etc下有一個DIR_COLORS的文件,這是一個著色控制的模版。現將這個模版拷出來。如果想讓這個配置在root用戶下生效,邊拷到 /root下;如果想在abc(例子)用戶下生效,便拷到/home/abc/下。之后將文件改名為(注意小寫,和“.”號).dir_colors
用 vi打開他,往下找,就會發現,一處標記者DIR的行,行的右邊,兩個兩位的十進制數,并且這兩個字的顏色是不同的。這就是對文件項目中文件夾 (directory)的著色方案。那兩個數便是所用的顏色。右邊那個便是用ls是顯示的顏色。隨便改一下,便會發現數字的顏色也跟著變化。這就使將來可 能的顏色了。
在DIR行的下面,還有其他類型的文件著色方案,同樣的格式,改改試試就行了。
之后,存盤。關掉命令行窗口。
再次打開命令行,便會卡看到你修改過后的結果了。很有意思。
在DIR_COLORS的文件頂端,有修改的說明和不同顏色對應的數字,可以作為參考。
-----------------------------------------------------------------------------------------------------------------------
Linux 在命令行方式中,默認 的目錄 顯示顏色 為藍色,在黑色背景下難以看清。
現介紹一種修改顯示顏色 的方法:
1、將/etc/DIR_COLORS文件cp到~/下,并改名為.dir_colors。
2、編輯.dir_colors文件,找到“DIR 01;34?? # directory”,將34改為36。
你可以找到文件的兩行注釋:
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
按照顏色 對應的數字,你還可以把目錄 顯示顏色 改成其他的。
同樣其他的顯示效果(包括背景)也可以參照說明進行修改。
這樣你就可以定制自己的linux 下命令行方式下的個性化顯示效果了。
-----------------------------------------------------------------------------------------------------------------------
linux 命令行中目錄
顏色 的修改
2009-08-29 10:52
Linux 命令行中目錄默認的顏色 為藍色,在黑色背景下難以看清。
修改顯示顏色 的方法:
打開/etc/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.
根據注釋 拷貝該文件到~/家目錄下,并改名為.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
# 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;36?????? # 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
找到“DIR 01;34 # directory ”,將34改為36。
找到文件的兩行注釋 :
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
按照顏色 對應的數字,你還可以把目錄顯示顏色 改成其他的,重新登陸shell即可看到效果。