所以,我发现了.dir_colors文件。因此,我对其进行了配置,并将以下内容添加到我的~/.bashrc文件中:
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dir_colors && eval "$(dircolors -b ~/.dir_colors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
fi这不管用。不知道为什么,但是LS_COLORS变量是''。当我手动运行dircolors -b ~/.dir_colors时,我看到:
LS_COLORS='';
export LS_COLORS知道为什么会这样吗?
更新:
下面是我的.dir_colors文件的内容:
# 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.
# -b = better support for special characters
OPTIONS -F -b -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 xterm
TERM vt100
# TERM alacritty
# 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 # 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;30
# 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
.tar 00;34 # archives or compressed (bright red)
.tgz 00;34
.arj 00;34
.taz 00;34
.lzh 00;34
.zip 00;34
.z 00;34
.Z 00;34
.gz 00;34
.bz2 00;34
.jpg 00;36 # image formats
.gif 00;36
.bmp 00;36
.xbm 00;36
.xpm 00;36
.tif 00;36
.tga 00;36
.png 00;36
.jpeg 00;36
.tiff 00;36
.xcf 00;36
.xcf.gz 00;36
.blend 00;36
.pcx 00;36
.ppm 00;36
.mp3 00;32
.mid 00;32
.wav 00;32
.au 00;32
.nes 00;31
.smc 00;31
.fig 00;31
.sfc 00;31
.smc.gz 00;31
.fig.gz 00;31
.sfc.gz 00;31
.mpg 00;35
.mpeg 00;35
.avi 00;35
.mov 00;35
.fli 00;35
.flc 00;35发布于 2020-07-10 17:10:49
似乎您没有添加正在使用的终端类型的值。如果我更改行,您的.dir_colors文件对我有效。
TERM xterm至
TERM xterm*或者如果我再加上一行
XTERM xterm-256color因为xterm-256color是我的TERM变量的值。
来自man dir_colors:
在全局部分之后是一个或多个特定于终端的部分,前面有一个或多个
TERM语句,这些语句指定终端类型(如TERM环境变量所提供的),下面的声明适用于。
https://unix.stackexchange.com/questions/597761
复制相似问题