Next: , Previous: , Up: The end user’s perspective   [Contents][Index]


2.5 The --color option

The ‘--color=when’ option specifies under which conditions styled (colorized) output should be generated. The when part can be one of the following:

always
yes

The output will be colorized.

never
no

The output will not be colorized.

auto
tty

The output will be colorized if the output device is a tty, i.e. when the output goes directly to a text screen or terminal emulator window.

html

The output will be colorized and be in HTML format. This value is only supported by some programs.

test

This is a special value, understood only by some programs. It is explained in the section (The environment variable TERM) above.

--color’ is equivalent to ‘--color=yes’. The default is ‘--color=auto’.

Thus, a command that invokes a libtextstyle-enabled program will produce colorized output when called by itself in a command window. Whereas in a pipe, such as ‘program arguments | less -R’, it will not produce colorized output. To get colorized output in this situation nevertheless, use the command ‘program --color arguments | less -R’.

The ‘--color=html’ option will produce output that can be viewed in a browser. This can be useful, for example, for Indic languages, because the renderic of Indic scripts in browsers is usually better than in terminal emulators.

Note that the output produced with the --color option is not consumable by programs that expect the raw text. It contains additional terminal-specific escape sequences or HTML tags. For example, an XML parser will give a syntax error when confronted with a colored XML output. Except for the ‘--color=html’ case, you therefore normally don’t need to save output produced with the --color option in a file.


Next: The --style option, Previous: Emacs as a terminal emulator, Up: The end user’s perspective   [Contents][Index]