.TH DIRCOLORS 1L \" -*- nroff -*-
.SH NAME
dircolors \- Set color parameters for 
.BR ls (1)
.SH SYNOPSIS
.TP
\fBeval `dircolors\fR [\-abckstzPS] [filename]\fB`\fR
.TP
.B dircolors \-v
.SH DESCRIPTION
.B dircolors
is a program to generate a setup for the color version of GNU 
.BR ls .
The setup consists of an
.B LS_COLORS
environment variable and a set of aliases.  For
.B sh
and
.BR ash ,
which lack aliases, shell functions are substituted.  The
.B dircolors
command will generally be run from the user's
.IR .profile ,
.I .cshrc
or equivalent file, or the system-wide equivalents.
.SS OPTIONS
.TP
.I "\-a, \-s"
Assume the user is using a Bourne-style shell which does not support
aliasing.  This is default if the base name of the environment
variable
.B SHELL
is
.B sh
or
.BR ash .
Instead a shell function is used.  If the
.I \-P
option is also used, this function will need to spawn a subshell; this
is slow and should be avoided if possible.
.TP
.I "\-b, \-k"
Assume the user is using a Bourne-style shell that supports Korn-style
aliasing.  This is the default if the base name of the environment
variable
.B SHELL
is
.B bash
or
.BR ksh .
You may want to specify this option explicitly if your
.B sh
is really a more advanced shell, which does support Korn-style aliasing.
.TP
.I "\-z"
Assume the user is using a Bourne-style shell that supports Korn-style
aliasing, but differs between string and list environment variables.
This is the default is the base name of the environment variable
.B SHELL
is
.BR zsh .
.TP
.I "\-c, \-t"
Assume the user is using a C-style shell.  This is the default if the
base name of the environment variable
.B SHELL
is
.B csh
or
.BR tcsh .
.TP
.I "\-P"
Do not seek the path to find the location of the
.B ls
binary.  By default,
.B dircolors
will find the location of the
.B ls
binary at the time it is run, and include it in the shell function or
alias, which for most shells results in a significant speed
improvement.
.TP
.I "\-S"
Set colorization to
.I no
if the terminal does not occur in any
.B TERM
statement, even if there is a
.B COLOR
statement in the global section of the file.  This is for
compatibility with Slackware GNU
.B ls
for which the order of the statements did not matter.
.TP
.I "\-v"
Display a version string and exit.
.SS CONFIGURATION FILE
If a filename is specified on the command line, it will be used to
generate the setup, if not, the file
.B .dir_colors
in the users home directory will be used.  If that file does not exist
either, the system-wide file of
.B /usr/etc/DIR_COLORS
will be used.
.PP
The configuration file consists of several statements, one per line.
Anything right of a hash mark (\#) is treated as a comment, if the
hash mark is at the beginning of a line or is preceded by at least one
whitespace.  Blank lines are ignored.
.PP
The
.I global
section of the file consists of any statement before the first
.B TERM
statement.  Any statement in the global section of the file is
considered valid for all terminal types  Following the global section
is one or more 
.I terminal-specific
sections, which are preceded by one or more
.B TERM
statements which specify the terminal types (as given by the
.B TERM
environment variable) the following declarations apply for.  It is
always possible to override a global declaration by a subsequent
terminal-specific one.
.PP
The following statements are recognized, case is insignificant:
.PP
.TP
.B TERM \fIterminal-type\fR
Starts a terminal-specific section and specifies which terminal it
applies to.  Multiple
.B TERM
statements can be used to create a section which applies for several
terminal types.
.TP
.B COLOR yes|all|no|none|tty
Specifies that colorization should be always enabled (\fIyes\fR or
\fIall\fR), never enabled (\fIno\fR or \fInone\fR) or enabled only if
the output is a terminal (\fItty\fR).  The default is \fIno\fR.
.TP
.B EIGHTBIT yes|no
Specifies that eight-bit ISO 8859 characters should be enabled by
default.  Can for compatibility reasons also be specified as 1 for
\fIyes\fR or 0 for \fIno\fR.  The default is \fIno\fR.
.TP
.B OPTIONS \fIoptions\fR
Adds command line options to the default
.B ls
command line.  The options can be any valid
.B ls
command line options, and should include the leading minus sign.
Please note that
.B dircolors
does not verify the validity of these options.
.TP
.B NORMAL \fIcolor-sequence\fR
Specifies the color used for normal (non-filename) text.
.TP
.B FILE \fIcolor-sequence\fR
Specifies the color used for a regular file.
.TP
.B DIR \fIcolor-sequence\fR
Specifies the color used for directories.
.TP
.B LINK \fIcolor-sequence\fR
Specifies the color used for a symbolic link.
.TP
.B ORPHAN \fIcolor-sequence\fR
Specifies the color used for an orphanned symbolic link (one which
points to a nonexistent file).  If this is unspecified,
.B ls
will use the
.B LINK
color instead.
.TP
.B MISSING \fIcolor-sequence\fR
Specifies the color used for a missing file (a nonexistent file which
nevertheless has a symbolic link pointing to it).  If this is unspecified,
.B ls
will use the
.B FILE
color instead.
.TP
.B FIFO \fIcolor-sequence\fR
Specifies the color used for a FIFO (named pipe).
.TP
.B SOCK \fIcolor-sequence\fR
Specifies the color used for a socket.
.TP
.B BLK \fIcolor-sequence\fR
Specifies the color used for a block device special file.
.TP
.B CHR \fIcolor-sequence\fR
Specifies the color used for a character device special file.
.TP
.B EXEC \fIcolor-sequence\fR
Specifies the color used for a file with the executable attribute set.
.TP
.B LEFTCODE \fIcolor-sequence\fR
Specifies the
.I "left code"
for non-ISO\ 6429 terminals (see below).
.TP
.B RIGHTCODE \fIcolor-sequence\fR
Specifies the
.I "right code"
for non-ISO\ 6429 terminals (see below).
.TP
.B ENDCODE \fIcolor-sequence\fR
Specifies the
.I "end code"
for non-ISO\ 6429 terminals (see below).
.TP
\fB*\fIextension\fR \fIcolor-sequence\fR
Specifies the color used for any file that ends in \fIextension\fR.
.TP
\fB .\fIextension\fR \fIcolor-sequence\fR
Same as \fB*\fR.\fIextension\fR.  Specifies the color used for any file that
ends in .\fIextension\fR.  Note that the period is included in the
extension, which makes it impossible to specify an extension not
starting with a period, such as
.B ~
for
.B emacs
backup files.  This form should be considered obsolete.
.SH ISO 6429 (ANSI) COLOR SEQUENCES
Most color-capable ASCII terminals today use ISO 6429 (ANSI) color sequences,
and many common terminals without color capability, including
.B xterm
and the widely used and cloned DEC VT100, will recognize ISO 6429 color
codes and harmlessly eliminate them from the output or emulate them.
.B ls
uses ISO 6429 codes by default, assuming colorization is enabled.

ISO 6429 color sequences are composed of sequences of numbers
separated by semicolons.  The most common codes are:
.sp
.RS +.2i
.ta 1.0i
.nf
 0	to restore default color
 1	for brighter colors 
 4	for underlined text
 5	for flashing text
30	for black foreground
31	for red foreground
32	for green foreground
33	for yellow (or brown) foreground
34	for blue foreground
35	for purple foreground
36	for cyan foreground
37	for white (or gray) foreground
40	for black background
41	for red background
42	for green background
43	for yellow (or brown) background
44	for blue background
45	for purple background
46	for cyan background
47	for white (or gray) background
.fi
.RE
.sp
Not all commands will work on all systems or display devices.
.PP
.B ls
uses the following defaults:
.sp
.RS +.2i
.ta 1.0i 2.5i
.nf
\fBNORMAL\fR	0	Normal (non-filename) text
\fBFILE\fR	0	Regular file
\fBDIR\fR	32	Directory
\fBLINK\fR	36	Symbolic link
\fBORPHAN\fR	undefined	Orphanned symbolic link
\fBMISSING\fR	undefined	Missing file
\fBFIFO\fR	31	Named pipe (FIFO)
\fBSOCK\fR	33	Socket
\fBBLK\fR	44;37	Block device
\fBCHR\fR	44;37	Character device
\fBEXEC\fR	35	Executable file
.fi
.RE
.sp
A few terminal programs do not recognize the default 
properly.  If all text gets colorized after you do a directory
listing, change the
.B NORMAL
and
.B FILE
codes to the numerical codes for your normal foreground and background
colors.
.SH OTHER TERMINAL TYPES (ADVANCED CONFIGURATION)
If you have a color-capable (or otherwise highlighting) terminal (or
printer!) which uses a different set of codes, you can still generate
a suitable setup.  To do so you will have to use the
.BR LEFTCODE ,
.BR RIGHTCODE ,
and
.BR ENDCODE
definitions.
.PP
When writing out a filename,
.B ls
generates the following output sequence:
.B LEFTCODE
.I typecode
.B RIGHTCODE
.I filename
.BR ENDCODE ,
where the
.I typecode
is the color sequence that depends on the type or name of file.  If the
.B ENDCODE
is undefined, the sequence
.B "LEFTCODE NORMAL RIGHTCODE"
will be used instead.  The purpose of the left- and rightcodes is
merely to reduce the amount of typing necessary (and to hide ugly
escape codes away from the user).  If they are not appropriate for
your terminal, you can eliminate them by specifying the respective
keyword on a line by itself.
.PP
.B NOTE:
If the
.B ENDCODE
is defined in the global section of the setup file, it
.I cannot
be undefined in a terminal-specific section of the file.  This means
any
.B NORMAL
definition will have no effect.  A different
.B ENDCODE
can however be specified, which would have the same effect.
.SH ESCAPE SEQUENCES
To specify control- or blank characters in the color sequences or
filename extensions, either C-style \e-escaped notation, or
.BR stty -style
^-notation can be used.  The C-style notation
includes the following characters:
.sp
.RS +.2i
.ta 1.0i
.nf
\fB\ea\fR	Bell (ASCII 7)
\fB\eb\fR	Backspace (ASCII 8)
\fB\ee\fR	Escape (ASCII 27)
\fB\ef\fR	Form feed (ASCII 12)
\fB\en\fR	Newline (ASCII 10)
\fB\er\fR	Carriage Return (ASCII 13)
\fB\et\fR	Tab (ASCII 9)
\fB\ev\fR	Vertical Tab (ASCII 11)
\fB\e?\fR	Delete (ASCII 127)
\fB\e\fInnn\fR	Any character (octal notation)
\fB\ex\fInnn\fR	Any character (hexadecimal notation)
\fB\e_\fR	Space
\fB\e\e\fR	Backslash (\e)
\fB\e^\fR	Caret (^)
\fB\e#\fR	Hash mark (#)
.fi
.RE
.sp
Please note that escapes are necessary to enter a space, backslash,
caret or any control character anywhere in the string, as well as a
hash mark as the first character.
.SH NOTES
The default
.B LEFTCODE
and
.B RIGHTCODE
definitions, which are used by ISO 6429 terminals are:
.sp
.RS +.2i
.ta 1.0i
.nf
\fBLEFTCODE\fR	\ee[
\fBRIGHTCODE\fR	m
.fi
.RE
.sp
The default
.B ENDCODE
is undefined.
.SH AUTHOR
H. Peter Anvin <Peter.Anvin@linux.org> with input from Patrick
Volkerding, creator of the Slackware Linux distribution.
.SH BUGS
Currently is somewhat poorly integrated into the GNU fileutils
package.  For example, it does not support long options and is
probably pickier about POSIX violations (i.e. less portable) 
than the rest of the programs.
.PP
The support for non-ISO 6429 terminals is a kluge at the very best.
.SH FILES
.ta \w'/usr/etc/DIR_COLORS'u+3n
.nf
\fB/usr/etc/DIR_COLORS\fR	System-wide setup file
\fB~/.dir_colors\fR	User setup file
.fi
.SH SEE ALSO
.BR ls (1),
.BR stty (1),
.BR xterm (1)
