* PATCH: support colour codes from current GNU ls
@ 2008-04-20 6:36 Andrey Borzenkov
0 siblings, 0 replies; only message in thread
From: Andrey Borzenkov @ 2008-04-20 6:36 UTC (permalink / raw)
To: zsh-workers
[-- Attachment #1: Type: text/plain, Size: 4365 bytes --]
This adds support for more colors that are supported in current GNU fileutils.
I am not sure how to properly detect orphan and missing files; when colour
is computed information is no more available. Nor was "missing" used so far
it seems.
Index: Doc/Zsh/mod_complist.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/mod_complist.yo,v
retrieving revision 1.18
diff -u -p -r1.18 mod_complist.yo
--- Doc/Zsh/mod_complist.yo 8 Nov 2007 12:34:15 -0000 1.18
+++ Doc/Zsh/mod_complist.yo 20 Apr 2008 06:32:07 -0000
@@ -51,11 +51,31 @@ for block devices
item(tt(cd 44;37))(
for character devices
)
-item(tt(ex 35))(
-for executable files
+item(tt(or) var(none))(
+for a symlink to nonexistent file (default is the value defined for tt(fi));
+this code is currently not used
)
item(tt(mi) var(none))(
-for a non-existent file (default is the value defined for tt(fi))
+for a non-existent file (default is the value defined for tt(fi)); this code
+is currently not used
+)
+item(tt(su 37;41))(
+for files with setuid bit set
+)
+item(tt(sg 30;43))(
+for files with setgid bit set
+)
+item(tt(tw 30;42))(
+for world writable directories with sticky bit set
+)
+item(tt(ow 34;43))(
+for world writable directories without sticky bit set
+)
+item(tt(st 37;44))(
+for directories with sticky bit set but not world writable
+)
+item(tt(ex 35))(
+for executable files
)
item(tt(lc \e[))(
for the left code (see below)
Index: Src/Zle/complist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complist.c,v
retrieving revision 1.110
diff -u -p -r1.110 complist.c
--- Src/Zle/complist.c 13 Apr 2008 16:58:42 -0000 1.110
+++ Src/Zle/complist.c 20 Apr 2008 06:32:07 -0000
@@ -177,30 +177,38 @@ static Keymap mskeymap, lskeymap;
#define COL_SO 5
#define COL_BD 6
#define COL_CD 7
-#define COL_EX 8
+#define COL_OR 8
#define COL_MI 9
-#define COL_LC 10
-#define COL_RC 11
-#define COL_EC 12
-#define COL_TC 13
-#define COL_SP 14
-#define COL_MA 15
-#define COL_HI 16
-#define COL_DU 17
+#define COL_SU 10
+#define COL_SG 11
+#define COL_TW 12
+#define COL_OW 13
+#define COL_ST 14
+#define COL_EX 15
+#define COL_LC 16
+#define COL_RC 17
+#define COL_EC 18
+#define COL_TC 19
+#define COL_SP 20
+#define COL_MA 21
+#define COL_HI 22
+#define COL_DU 23
-#define NUM_COLS 18
+#define NUM_COLS 24
/* Names of the terminal strings. */
static char *colnames[] = {
- "no", "fi", "di", "ln", "pi", "so", "bd", "cd", "ex", "mi",
+ "no", "fi", "di", "ln", "pi", "so", "bd", "cd", "or", "mi",
+ "su", "sg", "tw", "ow", "st", "ex",
"lc", "rc", "ec", "tc", "sp", "ma", "hi", "du", NULL
};
/* Default values. */
static char *defcols[] = {
- "0", "0", "1;31", "1;36", "33", "1;35", "1;33", "1;33", "1;32", NULL,
+ "0", "0", "1;31", "1;36", "33", "1;35", "1;33", "1;33", NULL, NULL,
+ "37;41", "30;43", "30;42", "34;42", "37;44", "1;32",
"\033[", "m", NULL, "0", "0", "7", NULL, NULL
};
@@ -507,7 +515,9 @@ getcols()
lr_caplen = strlen(mcolors.files[COL_LC]->col) +
strlen(mcolors.files[COL_RC]->col);
- /* Default for missing files. */
+ /* Default for orphans and missing files. Currently not used */
+ if (!mcolors.files[COL_OR] || !mcolors.files[COL_OR]->col)
+ mcolors.files[COL_OR] = mcolors.files[COL_FI];
if (!mcolors.files[COL_MI] || !mcolors.files[COL_MI]->col)
mcolors.files[COL_MI] = mcolors.files[COL_FI];
@@ -872,9 +882,17 @@ putfilecol(char *group, char *n, mode_t
return 0;
}
- if (S_ISDIR(m))
- colour = COL_DI;
- else if (S_ISLNK(m))
+ if (S_ISDIR(m)) {
+ if (m & S_IWOTH)
+ if (m & S_ISVTX)
+ colour = COL_TW;
+ else
+ colour = COL_OW;
+ else if (m & S_ISVTX)
+ colour = COL_ST;
+ else
+ colour = COL_DI;
+ } else if (S_ISLNK(m))
colour = COL_LN;
else if (S_ISFIFO(m))
colour = COL_PI;
@@ -884,6 +902,10 @@ putfilecol(char *group, char *n, mode_t
colour = COL_BD;
else if (S_ISCHR(m))
colour = COL_CD;
+ else if (m & S_ISUID)
+ colour = COL_SU;
+ else if (m & S_ISGID)
+ colour = COL_SG;
else if (S_ISREG(m) && (m & S_IXUGO))
colour = COL_EX;
else
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-04-20 6:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-20 6:36 PATCH: support colour codes from current GNU ls Andrey Borzenkov
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).