crayon (version 1.3.2)

has_color: Does the current R session support ANSI colors?

Description

Does the current R session support ANSI colors?

Usage

has_color()

Arguments

Value

TRUE if the current R session supports color.

Details

The following algorithm is used to detect ANSI support:
  • If the crayon.enabled option is set to TRUE with options(), then TRUE is returned. If it is set to something else than TRUE (typically FALSE), then FALSE is returned.
  • Otherwise, if the standard output is not a terminal, then FALSE is returned.
  • Otherwise, if the platform is Windows, TRUE is returned if running in ConEmu (https://conemu.github.io/) or cmder (http://cmder.net) with ANSI color support. Otherwise FALSE is returned.
  • Otherwise, if the COLORTERM environment variable is set, TRUE is returned.
  • Otherwise, if the TERM environment variable starts with screen, xterm or vt100, or matches color, ansi, cygwin or linux (with case insentive matching), then TRUE is returned.
  • Otherwise FALSE is returned.

Examples

Run this code
has_color()

Run the code above in your browser using DataLab