ANSI Color Codes Explained - rebeccajennifer/color-scheme-creator GitHub Wiki
This is ChatGPT's explanation for the different ANSI Color Codes.
ANSI color codes, as used in terminals, can be categorized into three main types: 16 colors, 256 colors, and 24-bit true colors. Hereβs an overview of each, along with some additional variations.
This is the original set of terminal colors defined by the ANSI standard.
-
Foreground Codes:
30β37
for standard colors,90β97
for bright versions. -
Background Codes:
40β47
for standard colors,100β107
for bright versions. - Includes attributes for bold, underline, etc., which can alter appearance.
Code | Color Name | Bright Version |
---|---|---|
30 | Black | 90 |
31 | Red | 91 |
32 | Green | 92 |
33 | Yellow | 93 |
34 | Blue | 94 |
35 | Magenta | 95 |
36 | Cyan | 96 |
37 | White | 97 |
This adds more colors for modern terminals and breaks down into:
-
16 Base Colors (0β15):
- The original 16 colors, now accessible as part of the 256-color space.
- These map to the same values as the 16-color codes.
-
216 Color Cube (16β231):
- A 6x6x6 RGB cube with varying intensities of red, green, and blue.
- Example:
16
is black (R=0, G=0, B=0
),231
is white (R=255, G=255, B=255
).
-
Grayscale (232β255):
- 24 shades of gray, from near-black (232) to near-white (255).
Supported by most modern terminals, 24-bit true color allows you to specify exact RGB values.
-
Foreground Format:
\e[38;2;<R>;<G>;<B>m
-
Background Format:
\e[48;2;<R>;<G>;<B>m
Example:
echo -e "\e[38;2;255;0;0mThis is bright red text\e[0m"
-
38
for foreground, 48 for background. -
<R>
,<G>
,<B>
represent red, green, and blue values (0β255).