如何配置.dir_colors

如何配置.dir_colors

所以,我发现了这个文件.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

答案1

您似乎没有添加您正在使用的终端类型的值。.dir_colors如果我改变线路,你的文件对我有用

TERM xterm

TERM xterm*

或者如果我添加额外的一行

XTERM xterm-256color

因为xterm-256color是我的变量的值TERM

man dir_colors

全局部分之后是一个或多个特定于终端的部分,前面是一个或多个指定以下声明适用的TERM终端类型(由环境变量给定)的语句。TERM

相关内容