has_color {crayon}R Documentation

Does the current R session support ANSI colors?

Description

Does the current R session support ANSI colors?

Usage

has_color()

Details

The following algorithm is used to detect ANSI support:

Value

TRUE if the current R session supports color.

Sinks

Note that has_color() returns FALSE if a sink is active (see sink()). It assumes that the constructed string will be printed to the standard output, and sink() redirects to a file, and usually you don't want ANSI colors in the file.

The same applies to the case when R's standard output is redirected to a file, from the command line, e.g.:

R -q -e 'cat(crayon::red("no color here\n"))' > /tmp/crayon-test.txt
cat /tmp/crayon-test.txt

Examples

has_color()

[Package crayon version 1.3.4 Index]