head 1.9; access; symbols pkgsrc-2026Q1:1.9.0.78 pkgsrc-2026Q1-base:1.9 pkgsrc-2025Q4:1.9.0.76 pkgsrc-2025Q4-base:1.9 pkgsrc-2025Q3:1.9.0.74 pkgsrc-2025Q3-base:1.9 pkgsrc-2025Q2:1.9.0.72 pkgsrc-2025Q2-base:1.9 pkgsrc-2025Q1:1.9.0.70 pkgsrc-2025Q1-base:1.9 pkgsrc-2024Q4:1.9.0.68 pkgsrc-2024Q4-base:1.9 pkgsrc-2024Q3:1.9.0.66 pkgsrc-2024Q3-base:1.9 pkgsrc-2024Q2:1.9.0.64 pkgsrc-2024Q2-base:1.9 pkgsrc-2024Q1:1.9.0.62 pkgsrc-2024Q1-base:1.9 pkgsrc-2023Q4:1.9.0.60 pkgsrc-2023Q4-base:1.9 pkgsrc-2023Q3:1.9.0.58 pkgsrc-2023Q3-base:1.9 pkgsrc-2023Q2:1.9.0.56 pkgsrc-2023Q2-base:1.9 pkgsrc-2023Q1:1.9.0.54 pkgsrc-2023Q1-base:1.9 pkgsrc-2022Q4:1.9.0.52 pkgsrc-2022Q4-base:1.9 pkgsrc-2022Q3:1.9.0.50 pkgsrc-2022Q3-base:1.9 pkgsrc-2022Q2:1.9.0.48 pkgsrc-2022Q2-base:1.9 pkgsrc-2022Q1:1.9.0.46 pkgsrc-2022Q1-base:1.9 pkgsrc-2021Q4:1.9.0.44 pkgsrc-2021Q4-base:1.9 pkgsrc-2021Q3:1.9.0.42 pkgsrc-2021Q3-base:1.9 pkgsrc-2021Q2:1.9.0.40 pkgsrc-2021Q2-base:1.9 pkgsrc-2021Q1:1.9.0.38 pkgsrc-2021Q1-base:1.9 pkgsrc-2020Q4:1.9.0.36 pkgsrc-2020Q4-base:1.9 pkgsrc-2020Q3:1.9.0.34 pkgsrc-2020Q3-base:1.9 pkgsrc-2020Q2:1.9.0.30 pkgsrc-2020Q2-base:1.9 pkgsrc-2020Q1:1.9.0.10 pkgsrc-2020Q1-base:1.9 pkgsrc-2019Q4:1.9.0.32 pkgsrc-2019Q4-base:1.9 pkgsrc-2019Q3:1.9.0.28 pkgsrc-2019Q3-base:1.9 pkgsrc-2019Q2:1.9.0.26 pkgsrc-2019Q2-base:1.9 pkgsrc-2019Q1:1.9.0.24 pkgsrc-2019Q1-base:1.9 pkgsrc-2018Q4:1.9.0.22 pkgsrc-2018Q4-base:1.9 pkgsrc-2018Q3:1.9.0.20 pkgsrc-2018Q3-base:1.9 pkgsrc-2018Q2:1.9.0.18 pkgsrc-2018Q2-base:1.9 pkgsrc-2018Q1:1.9.0.16 pkgsrc-2018Q1-base:1.9 pkgsrc-2017Q4:1.9.0.14 pkgsrc-2017Q4-base:1.9 pkgsrc-2017Q3:1.9.0.12 pkgsrc-2017Q3-base:1.9 pkgsrc-2017Q2:1.9.0.8 pkgsrc-2017Q2-base:1.9 pkgsrc-2017Q1:1.9.0.6 pkgsrc-2017Q1-base:1.9 pkgsrc-2016Q4:1.9.0.4 pkgsrc-2016Q4-base:1.9 pkgsrc-2016Q3:1.9.0.2 pkgsrc-2016Q3-base:1.9 pkgsrc-2016Q2:1.8.0.8 pkgsrc-2016Q2-base:1.8 pkgsrc-2016Q1:1.8.0.6 pkgsrc-2016Q1-base:1.8 pkgsrc-2015Q4:1.8.0.4 pkgsrc-2015Q4-base:1.8 pkgsrc-2015Q3:1.8.0.2 pkgsrc-2015Q3-base:1.8 pkgsrc-2015Q2:1.7.0.90 pkgsrc-2015Q2-base:1.7 pkgsrc-2015Q1:1.7.0.88 pkgsrc-2015Q1-base:1.7 pkgsrc-2014Q4:1.7.0.86 pkgsrc-2014Q4-base:1.7 pkgsrc-2014Q3:1.7.0.84 pkgsrc-2014Q3-base:1.7 pkgsrc-2014Q2:1.7.0.82 pkgsrc-2014Q2-base:1.7 pkgsrc-2014Q1:1.7.0.80 pkgsrc-2014Q1-base:1.7 pkgsrc-2013Q4:1.7.0.78 pkgsrc-2013Q4-base:1.7 pkgsrc-2013Q3:1.7.0.76 pkgsrc-2013Q3-base:1.7 pkgsrc-2013Q2:1.7.0.74 pkgsrc-2013Q2-base:1.7 pkgsrc-2013Q1:1.7.0.72 pkgsrc-2013Q1-base:1.7 pkgsrc-2012Q4:1.7.0.70 pkgsrc-2012Q4-base:1.7 pkgsrc-2012Q3:1.7.0.68 pkgsrc-2012Q3-base:1.7 pkgsrc-2012Q2:1.7.0.66 pkgsrc-2012Q2-base:1.7 pkgsrc-2012Q1:1.7.0.64 pkgsrc-2012Q1-base:1.7 pkgsrc-2011Q4:1.7.0.62 pkgsrc-2011Q4-base:1.7 pkgsrc-2011Q3:1.7.0.60 pkgsrc-2011Q3-base:1.7 pkgsrc-2011Q2:1.7.0.58 pkgsrc-2011Q2-base:1.7 pkgsrc-2011Q1:1.7.0.56 pkgsrc-2011Q1-base:1.7 pkgsrc-2010Q4:1.7.0.54 pkgsrc-2010Q4-base:1.7 pkgsrc-2010Q3:1.7.0.52 pkgsrc-2010Q3-base:1.7 pkgsrc-2010Q2:1.7.0.50 pkgsrc-2010Q2-base:1.7 pkgsrc-2010Q1:1.7.0.48 pkgsrc-2010Q1-base:1.7 pkgsrc-2009Q4:1.7.0.46 pkgsrc-2009Q4-base:1.7 pkgsrc-2009Q3:1.7.0.44 pkgsrc-2009Q3-base:1.7 pkgsrc-2009Q2:1.7.0.42 pkgsrc-2009Q2-base:1.7 pkgsrc-2009Q1:1.7.0.40 pkgsrc-2009Q1-base:1.7 pkgsrc-2008Q4:1.7.0.38 pkgsrc-2008Q4-base:1.7 pkgsrc-2008Q3:1.7.0.36 pkgsrc-2008Q3-base:1.7 cube-native-xorg:1.7.0.34 cube-native-xorg-base:1.7 pkgsrc-2008Q2:1.7.0.32 pkgsrc-2008Q2-base:1.7 cwrapper:1.7.0.30 pkgsrc-2008Q1:1.7.0.28 pkgsrc-2008Q1-base:1.7 pkgsrc-2007Q4:1.7.0.26 pkgsrc-2007Q4-base:1.7 pkgsrc-2007Q3:1.7.0.24 pkgsrc-2007Q3-base:1.7 pkgsrc-2007Q2:1.7.0.22 pkgsrc-2007Q2-base:1.7 pkgsrc-2007Q1:1.7.0.20 pkgsrc-2007Q1-base:1.7 pkgsrc-2006Q4:1.7.0.18 pkgsrc-2006Q4-base:1.7 pkgsrc-2006Q3:1.7.0.16 pkgsrc-2006Q3-base:1.7 pkgsrc-2006Q2:1.7.0.14 pkgsrc-2006Q2-base:1.7 pkgsrc-2006Q1:1.7.0.12 pkgsrc-2006Q1-base:1.7 pkgsrc-2005Q4:1.7.0.10 pkgsrc-2005Q4-base:1.7 pkgsrc-2005Q3:1.7.0.8 pkgsrc-2005Q3-base:1.7 pkgsrc-2005Q2:1.7.0.6 pkgsrc-2005Q2-base:1.7 pkgsrc-2005Q1:1.7.0.4 pkgsrc-2005Q1-base:1.7 pkgsrc-2004Q4:1.7.0.2 pkgsrc-2004Q4-base:1.7 pkgsrc-2004Q3:1.6.0.16 pkgsrc-2004Q3-base:1.6 pkgsrc-2004Q2:1.6.0.14 pkgsrc-2004Q2-base:1.6 pkgsrc-2004Q1:1.6.0.12 pkgsrc-2004Q1-base:1.6 pkgsrc-2003Q4:1.6.0.10 pkgsrc-2003Q4-base:1.6 netbsd-1-6-1:1.6.0.6 netbsd-1-6-1-base:1.6 netbsd-1-6:1.6.0.8 netbsd-1-6-RELEASE-base:1.6 pkgviews:1.6.0.4 pkgviews-base:1.6 buildlink2:1.6.0.2 buildlink2-base:1.6 netbsd-1-5-PATCH003:1.6 netbsd-1-5-PATCH001:1.6 netbsd-1-5-RELEASE:1.6 netbsd-1-4-PATCH003:1.6 netbsd-1-4-PATCH002:1.6 comdex-fall-1999:1.4 netbsd-1-4-PATCH001:1.4 netbsd-1-4-RELEASE:1.4 netbsd-1-3-PATCH003:1.4 netbsd-1-3-PATCH002:1.2 Makefile:1.1.1.1 FreeBSD-current-1997-09-25:1.1.1.1 FREEBSD:1.1.1; locks; strict; comment @# @; 1.9 date 2016.09.08.14.41.36; author jperkin; state Exp; branches; next 1.8; commitid 3C20UYcFUiDtLulz; 1.8 date 2015.07.09.11.44.09; author jperkin; state Exp; branches; next 1.7; commitid 8PWUs1MPC6CvvBsy; 1.7 date 2004.10.13.18.50.13; author tv; state Exp; branches; next 1.6; 1.6 date 2000.02.05.20.05.24; author wiz; state Exp; branches; next 1.5; 1.5 date 99.11.27.22.55.07; author rh; state Exp; branches; next 1.4; 1.4 date 98.08.07.11.10.12; author agc; state Exp; branches; next 1.3; 1.3 date 98.05.21.14.06.37; author frueauf; state Exp; branches; next 1.2; 1.2 date 97.10.24.00.59.27; author hubertf; state Exp; branches; next 1.1; 1.1 date 97.10.11.21.54.06; author hubertf; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 97.10.11.21.54.06; author hubertf; state Exp; branches; next ; desc @@ 1.9 log @Support PKGMANDIR. Use RESTRICTED correctly. @ text @$NetBSD: patch-aa,v 1.8 2015/07/09 11:44:09 jperkin Exp $ Use pkgsrc layout. --- Makefile.orig 1994-09-24 02:55:51.000000000 +0000 +++ Makefile @@@@ -3,4 +3,7 @@@@ -PROG= ls +PROG= colorls SRCS= cmp.c stat_flags.c ls.c print.c util.c +BINDIR= ${PREFIX}/bin +MANDIR= ${PREFIX}/${PKGMANDIR} +MANINSTALL= catinstall maninstall @ 1.8 log @Use nbcompat correctly, add patch comments. Fixes build on SunOS. @ text @d1 1 a1 1 $NetBSD: patch-aa,v 1.7 2004/10/13 18:50:13 tv Exp $ d13 1 a13 1 +MANDIR= ${PREFIX}/man @ 1.7 log @Defuzz patches by regenerating with pkgdiff. @ text @d1 1 a1 1 $NetBSD$ d3 3 a5 1 --- Makefile.orig Fri Sep 23 22:55:51 1994 @ 1.6 log @defuzzed @ text @d3 3 a5 3 --- Makefile.orig Sat Nov 27 23:51:20 1999 +++ Makefile Sat Nov 27 23:51:22 1999 @@@@ -3,5 +3,8 @@@@ a13 1 .include @ 1.5 log @defuzz @ text @d5 1 a5 3 @@@@ -1,7 +1,10 @@@@ # @@(#)Makefile 8.1 (Berkeley) 6/2/93 # $Id: Makefile,v 1.2 1994/09/24 02:55:51 davidg Exp $ @ 1.4 log @Add NetBSD RCS Ids. @ text @d3 2 a4 2 --- Makefile.orig Sat Sep 24 04:55:51 1994 +++ Makefile Thu May 21 15:44:37 1998 d7 1 a7 1 # $Id: patch-aa,v 1.3 1998/05/21 14:06:37 frueauf Exp $ @ 1.3 log @Handle MANZ case better and split the big patch file into one patch per file for better maintainance. @ text @d1 2 d7 1 a7 1 # $Id: Makefile,v 1.2 1994/09/24 02:55:51 davidg Exp $ @ 1.2 log @put manpages in ${PREFIX}/man, not ${PREFIX}/man/man @ text @d1 3 a3 251 --- ./ls.c.org Wed Mar 8 02:14:11 1995 +++ ./ls.c Wed Mar 8 02:17:10 1995 @@@@ -93,6 +93,7 @@@@ int f_dirname; /* if precede with directory name */ int f_timesort; /* sort by time vice name */ int f_type; /* add type character for non-regular files */ +int f_color; /* add type in color for non-regular files */ #ifndef BSD4_4_LITE int f_whiteout; /* show whiteout entries */ #endif @@@@ -135,9 +136,9 @@@@ fts_options = FTS_PHYSICAL; #ifdef BSD4_4_LITE - while ((ch = getopt(argc, argv, "1ACFLRTacdfgikloqrstu")) != EOF) { + while ((ch = getopt(argc, argv, "1ACFGLRTacdfgikloqrstu")) != EOF) { #else - while ((ch = getopt(argc, argv, "1ACFLRTWacdfgikloqrstu")) != EOF) { + while ((ch = getopt(argc, argv, "1ACFGLRTWacdfgikloqrstu")) != EOF) { #endif switch (ch) { /* @@@@ -152,6 +153,9 @@@@ case 'F': f_type = 1; break; + case 'G': + f_color = 1; + break; case 'L': fts_options &= ~FTS_PHYSICAL; fts_options |= FTS_LOGICAL; @@@@ -207,18 +211,21 @@@@ argc -= optind; argv += optind; + parsecolors(getenv("LSCOLORS")); + /* * If not -F, -i, -l, -s or -t options, don't require stat * information. */ - if (!f_inode && !f_longform && !f_size && !f_timesort && !f_type) + if (!f_inode && !f_longform && !f_size && !f_timesort && !f_type + && !f_color) fts_options |= FTS_NOSTAT; /* * If not -F, -d or -l options, follow any symbolic links listed on * the command line. */ - if (!f_longform && !f_listdir && !f_type) + if (!f_longform && !f_listdir && !f_type && !f_color) fts_options |= FTS_COMFOLLOW; #ifndef BSD4_4_LITE --- ./ls.h.org Wed Mar 8 02:14:11 1995 +++ ./ls.h Wed Mar 8 02:17:11 1995 @@@@ -49,6 +49,7 @@@@ extern int f_size; /* list size in short listing */ extern int f_statustime; /* use time of last mode change */ extern int f_type; /* add type character for non-regular files */ +extern int f_color; /* add type in color for non-regular files */ typedef struct { FTSENT *list; --- ./print.c.org Wed Mar 8 02:14:11 1995 +++ ./print.c Wed Mar 8 02:17:11 1995 @@@@ -66,6 +66,26 @@@@ #define IS_NOPRINT(p) ((p)->fts_number == NO_PRINT) +/* Most of these are taken from */ +typedef enum Colors { + C_DIR, /* directory */ + C_LNK, /* symbolic link */ + C_SOCK, /* socket */ + C_FIFO, /* pipe */ + C_EXEC, /* executable */ + C_BLK, /* block special */ + C_CHR, /* character special */ + C_SUID, /* setuid executable */ + C_SGID, /* setgid executable */ + C_WSDIR, /* directory writeble to others, with sticky bit */ + C_WDIR, /* directory writeble to others, without sticky bit */ + C_NUMCOLORS /* just a place-holder */ +} Colors ; + +char *defcolors = "4x5x2x3x1x464301060203"; + +static int colors[C_NUMCOLORS][2]; + void printscol(dp) DISPLAY *dp; @@@@ -122,10 +142,14 @@@@ printtime(sp->st_ctime); else printtime(sp->st_mtime); + if (f_color) + (void)colortype(sp->st_mode); (void)printf("%s", p->fts_name); if (f_type) (void)printtype(sp->st_mode); - if (S_ISLNK(sp->st_mode)) + if (f_color) + (void)printf("\033[m"); + if (S_ISLNK(sp->st_mode)) printlink(p); (void)putchar('\n'); } @@@@ -190,10 +214,22 @@@@ dp->s_block); if ((base += numrows) >= num) break; - while ((cnt = ((chcnt + TAB) & ~(TAB - 1))) <= endcol){ - (void)putchar('\t'); - chcnt = cnt; - } + + /* + * some terminals get confused if we mix tabs + * with color sequences + */ + if (f_color) + while ((cnt = (chcnt + 1)) <= endcol) { + (void)putchar(' '); + chcnt = cnt; + } + else + while ((cnt = ((chcnt + TAB) & ~(TAB - 1))) + <= endcol) { + (void)putchar('\t'); + chcnt = cnt; + } endcol += colwidth; } (void)putchar('\n'); @@@@ -217,9 +241,13 @@@@ if (f_size) chcnt += printf("%*qd ", (int)sizefield, howmany(sp->st_blocks, blocksize)); + if (f_color) + (void)colortype(sp->st_mode); chcnt += printf("%s", p->fts_name); if (f_type) chcnt += printtype(sp->st_mode); + if (f_color) + printf("\033[m"); return (chcnt); } @@@@ -274,6 +302,95 @@@@ return (0); } +void +printcolor(c) + Colors c; +{ + printf("\033["); + if (colors[c][0] != -1) { + printf("3%d", colors[c][0]); + if (colors[c][1] != -1) + printf(";"); + } + if (colors[c][1] != -1) + printf("4%d", colors[c][1]); + printf("m"); +} + +colortype(mode) + mode_t mode; +{ + switch(mode & S_IFMT) { + case S_IFDIR: + if (mode & S_IWOTH) + if (mode & S_ISTXT) + printcolor(C_WSDIR); + else + printcolor(C_WDIR); + else + printcolor(C_DIR); + return(1); + case S_IFLNK: + printcolor(C_LNK); + return(1); + case S_IFSOCK: + printcolor(C_SOCK); + return(1); + case S_IFIFO: + printcolor(C_FIFO); + return(1); + case S_IFBLK: + printcolor(C_BLK); + return(1); + case S_IFCHR: + printcolor(C_CHR); + return(1); + } + if (mode & (S_IXUSR | S_IXGRP | S_IXOTH)) { + if (mode & S_ISUID) + printcolor(C_SUID); + else if (mode & S_ISGID) + printcolor(C_SGID); + else + printcolor(C_EXEC); + return(1); + } + return(0); +} + +void +parsecolors(cs) +char *cs; +{ + int i, j, len; + char c[2]; + if (cs == NULL) cs = ""; /* LSCOLORS not set */ + len = strlen(cs); + for (i = 0 ; i < C_NUMCOLORS ; i++) { + if (len <= 2*i) { + c[0] = defcolors[2*i]; + c[1] = defcolors[2*i+1]; + } + else { + c[0] = cs[2*i]; + c[1] = cs[2*i+1]; + } + for (j = 0 ; j < 2 ; j++) { + if ((c[j] < '0' || c[j] > '7') && + tolower(c[j]) != 'x') { + fprintf(stderr, + "error: invalid character '%c' in LSCOLORS env var\n", + c[j]); + c[j] = defcolors[2*i+j]; + } + if (c[j] == 'x') + colors[i][j] = -1; + else + colors[i][j] = c[j]-'0'; + } + } +} + static void printlink(p) FTSENT *p; --- ./Makefile.org Wed Mar 8 02:14:10 1995 +++ ./Makefile Wed Mar 8 02:20:01 1995 @@@@ -1,7 +1,9 @@@@ d5 1 a5 1 # Makefile,v 1.2 1994/09/24 02:55:51 davidg Exp d12 1 a14 120 --- ./colorls.1.org Wed Mar 8 02:14:10 1995 +++ ./colorls.1 Wed Mar 8 02:17:10 1995 @@@@ -36,16 +36,24 @@@@ .\" ls.1,v 1.3 1994/09/24 02:55:53 davidg Exp .\" .Dd July 29, 1994 -.Dt LS 1 +.Dt COLORLS 1 .Os .Sh NAME -.Nm ls -.Nd list directory contents +.Nm colorls +.Nd list directory contents in color .Sh SYNOPSIS -.Nm ls -.Op Fl ACFLRTWacdfiloqrstu1 +.Nm colorls +.Op Fl ACFGLRTWacdfiloqrstu1 .Op Ar file ... .Sh DESCRIPTION +(Note: This man page describes the color version of the program. To +minimize the differences from the original, the program is referred to +as +.Nm ls +in this manual. The new option +.Fl G +is for color display.) +.Pp For each operand that names a .Ar file of a type other than @@@@ -87,6 +95,12 @@@@ a percent sign (%) after each whiteout, and a vertical bar (|) after each that is a .Tn FIFO . +.It Fl G +Use ANSI color sequences to distinguish file types. (See +.Ev LSCOLORS +below.) In addition to those mentioned above in +.Fl F , +some extra attributes (setuid bit set, etc.) are also displayed. .It Fl L If argument is a symbolic link, list the file or directory the link references rather than the link itself. @@@@ -314,6 +328,74 @@@@ See .Xr environ 7 for more information. +.It LSCOLORS +The value of this variable describes what color to use for which +attribute when the color output +.Pq Fl G +is specified. This string is a concatenation of pairs of the format +.Sy fb , +where +.Sy f +is the foreground color and +.Sy b +is the background color. +.Pp +The color designators are as follows: +.Pp +.Bl -tag -width 4n -offset indent -compact +.It Sy 0 +black +.It Sy 1 +red +.It Sy 2 +green +.It Sy 3 +yellow +.It Sy 4 +blue +.It Sy 5 +magenta +.It Sy 6 +cyan +.It Sy 7 +white +.It Sy x +default foreground or background +.El +.Pp +(Note: the above are standard ANSI colors. The actual display may +differ depending on the color capabilities of your terminal.) +.Pp +The order of the attributes are as follows: +.Pp +.Bl -enum -offset indent -compact +.It +directory +.It +symbolic link +.It +socket +.It +pipe +.It +executable +.It +block special +.It +character special +.It +executable with setuid bit set +.It +executable with setgid bit set +.It +directory writable to others, with sticky bit +.It +directory writable to others, without sticky bit +.El +.Pp +The default is "4x5x2x3x1x464301060203", i.e., blue foreground and +default background for regular directories, black foreground and red +background for setuid executables, etc. .El .Sh COMPATIBILITY The group field is now automatically included in the long listing for @ 1.1 log @Initial revision @ text @d259 1 a259 1 +MANDIR= ${PREFIX}/man/man @ 1.1.1.1 log @Import as of 09/25/97 @ text @@