使用 dircolors,如何更改 subversion 文件夹的颜色

使用 dircolors,如何更改 subversion 文件夹的颜色

下面是我的 dircolors 文件的示例,我希望 subversion 文件夹 (.svn) 被着色,但我猜扩展部分仅适用于文件名。

如何为具有特定名称的目录设置颜色?

NORMAL 00   # global default, although everything should be something.
FILE   00   # normal file
DIR    35   # 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

# 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 '#')
*~    01;33;41 # stuff we hate to find laying around (flashing red)
.svn  37
.cmd  01;32 # executables (bright green)
.exe  01;32
.com  01;32
.btm  01;32

答案1

我找到了一个方法:

diff --git a/src/ls.c b/src/ls.c
index 680a7c3..d316eb6 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -4226,7 +4226,7 @@ print_color_indicator (const struct fileinfo *f, bool symlink_target)

   /* Check the file's suffix only if still classified as C_FILE.  */
   ext = NULL;
-  if (type == C_FILE)
+  if (type == C_FILE || type == C_DIR)
     {
       /* Test if NAME has a recognized suffix.  */

在此输入图像描述

相关内容