Module: ColorConstants

Defined in:
lib/common/colorconstants.rb

Overview

Color constants so we can print onto console using print or puts

Examples:

string = "hello ruby"
puts " #{RED}#{BOLD}#{UNDERLINE}#{string}#{CLEAR}"

http://wiki.bash-hackers.org/scripting/terminalcodes
ripped off highline gem

Constant Summary

CLEAR =

Embed in a String to clear all previous ANSI sequences. This MUST be done before the program exits!

"\e[0m"
RESET =

An alias for CLEAR.

CLEAR
NORMAL =
CLEAR
ERASE_LINE =

Erase the current line of terminal output.

"\e[K"
ERASE_CHAR =

Erase the character under the cursor.

"\e[P"
BOLD =

The start of an ANSI bold sequence.

"\e[1m"
DARK =

The start of an ANSI dark sequence. (Terminal support uncommon.)

"\e[2m"
DIM =
DARK
UNDERLINE =

The start of an ANSI underline sequence.

"\e[4m"
UNDERSCORE =

An alias for UNDERLINE.

UNDERLINE
"\e[5m"
REVERSE =

The start of an ANSI reverse sequence.

"\e[7m"
CONCEALED =

The start of an ANSI concealed sequence. (Terminal support uncommon.)

"\e[8m"
BOLD_OFF =
"\e[22m"
UNDERILNE_OFF =
"\e[24m"
"\e[25m"
REVERSE_OFF =
"\e[27m"
BLACK =

Set the terminal’s foreground ANSI color to black.

"\e[30m"
RED =

Set the terminal’s foreground ANSI color to red.

"\e[31m"
GREEN =

Set the terminal’s foreground ANSI color to green.

"\e[32m"
YELLOW =

Set the terminal’s foreground ANSI color to yellow.

"\e[33m"
BLUE =

Set the terminal’s foreground ANSI color to blue.

"\e[34m"
MAGENTA =

Set the terminal’s foreground ANSI color to magenta.

"\e[35m"
CYAN =

Set the terminal’s foreground ANSI color to cyan.

"\e[36m"
WHITE =

Set the terminal’s foreground ANSI color to white.

"\e[37m"
ON_BLACK =

Set the terminal’s background ANSI color to black.

"\e[40m"
ON_RED =

Set the terminal’s background ANSI color to red.

"\e[41m"
ON_GREEN =

Set the terminal’s background ANSI color to green.

"\e[42m"
ON_YELLOW =

Set the terminal’s background ANSI color to yellow.

"\e[43m"
ON_BLUE =

Set the terminal’s background ANSI color to blue.

"\e[44m"
ON_MAGENTA =

Set the terminal’s background ANSI color to magenta.

"\e[45m"
ON_CYAN =

Set the terminal’s background ANSI color to cyan.

"\e[46m"
ON_WHITE =

Set the terminal’s background ANSI color to white.

"\e[47m"