我正在编辑 LS_COLORS 环境变量。dircolors
列出不同文件类型的默认颜色。文件类型表示如下:
bd = (BLOCK, BLK) Block device (buffered) special file
cd = (CHAR, CHR) Character device (unbuffered) special file
di = (DIR) Directory
do = (DOOR) [Door][1]
ex = (EXEC) Executable file (ie. has 'x' set in permissions)
fi = (FILE) Normal file
ln = (SYMLINK, LINK, LNK) Symbolic link. If you set this to ‘target’ instead of a numerical value, the color is as for the file pointed to.
mi = (MISSING) Non-existent file pointed to by a symbolic link (visible when you type ls -l)
no = (NORMAL, NORM) Normal (non-filename) text. Global default, although everything should be something
or = (ORPHAN) Symbolic link pointing to an orphaned non-existent file
ow = (OTHER_WRITABLE) Directory that is other-writable (o+w) and not sticky
pi = (FIFO, PIPE) Named pipe (fifo file)
sg = (SETGID) File that is setgid (g+s)
so = (SOCK) Socket file
st = (STICKY) Directory with the sticky bit set (+t) and not other-writable
su = (SETUID) File that is setuid (u+s)
tw = (STICKY_OTHER_WRITABLE) Directory that is sticky and other-writable (+t,o+w)
如何确定文件或目录属于这些类别中的哪一个?
我为 LS_COLORS 引用的链接:
使用file
不起作用;查询目录告诉我该目录是……一个目录。但很明显,它有一个未显示的文件类型标志file
,因为某些目录有一个绝对可怕的淡绿色突出显示白色文本。使用ls -lah
也不起作用;权限字符串的第一个字母是d
,这又是不够的信息。
Ubuntu 19.10 | KDE 等离子 5.16.5 | zsh 5.7.1
我不知道有一个程序会列出已知的文件类型
dircolors
。我怀疑没有,虽然这将是对 dircolors 的一个很好的补充但是你可以转储数据库并在那里找到你想要更改的那些。例如,对于目录:现在您知道有多少种不同类型的目录(对于
dicolors
,它们只是 的目录file
。检查浅绿色目录上白色的权限ls -ld your_directory
您还可以在系统中列出颜色及其含义。检查这个脚本。
我知道这些步骤并不完全符合您的要求:获取 dircolors 用于某个节点的文件类型。但是,在两者之间,它们应该有助于调试,并且您可以为那些无法找到的文件类型调整颜色。