Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
ANSI escape code
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== {{anchor|SGR}} Select Graphic Rendition parameters == The control sequence <code>CSI {{var|n}} m</code>, named Select Graphic Rendition (SGR), sets display attributes. Several attributes can be set in the same sequence, separated by semicolons.<ref name="console_codes(4)">{{Cite web|url=http://man7.org/linux/man-pages/man4/console_codes.4.html|title=console_codes(4) - Linux manual page|website=man7.org|access-date=2018-03-23}}</ref> Each display attribute remains in effect until a following occurrence of SGR resets it.<ref name="ECMA-48" /> If no codes are given, {{code|CSI m}} is treated as {{code|CSI 0 m}} (reset / normal). {| class="wikitable" ! ''n''!! Name !! Note |- | {{tt|0}} | Reset ''or'' normal | All attributes become turned off |- | {{tt|1}} | Bold or increased intensity | As with faint, the color change is a PC (SCO / [[Color Graphics Adapter|CGA]]) invention.<ref name=SCO>{{cite web |title=screen(HW) |url=http://osr507doc.sco.com/man/html.HW/screen.HW.html |website=SCO OpenServer Release 5.0.7 Manual |date=11 February 2003}}</ref>{{better source needed|date=June 2020}} |- | {{tt|2}} | Faint, decreased intensity, ''or'' dim |<!-- dim (with a saturated color). --> May be implemented as a light [[font weight]] like bold.<ref>{{cite web |title=Bug 791596 β Thoughts about faint (SGR 2) |url=https://bugzilla.gnome.org/show_bug.cgi?id=791596 |website=bugzilla.gnome.org}}</ref> |- | {{tt|3}} | Italic | Not widely supported. Sometimes treated as inverse or blink.<ref name=SCO/> |- | {{tt|4}} | Underline | Style extensions exist for Kitty, VTE, mintty, iTerm2 and Konsole.<ref name=color-u>{{cite web |title=Curly and colored underlines (#6382) Β· Issues Β· George Nachman / iterm2 |url=https://gitlab.com/gnachman/iterm2/-/issues/6382 |website=GitLab |date=11 December 2017 |language=en}}</ref><ref name=color-u-kitty-spec>{{cite web |title=Extensions to the xterm protocol |url=https://sw.kovidgoyal.net/kitty/protocol-extensions.html#colored-and-styled-underlines |website=kitty documentation |language=en |access-date=2020-07-01}}</ref><ref name=color-u-konsole>{{cite web |title=Curly and colored underlines |url=https://bugs.kde.org/387811 |website=KDE bugtracker |date=27 August 2022 |language=en}}</ref> |- | {{tt|5}} | Slow blink | Sets blinking to less than 150 times per minute |- | {{tt|6}} | Rapid blink | MS-DOS ANSI.SYS, 150+ per minute; not widely supported |- | {{tt|7}} | [[Reverse video]] ''or'' invert | Swap foreground and background colors; inconsistent emulation<ref name=console-termio-realize>{{cite web |title=console-termio-realizer |url=http://jdebp.uk/Softwares/nosh/guide/commands/console-termio-realizer.xml |website=jdebp.uk}}</ref>{{dubious|inconsistent emulation|date=April 2023}} |- | {{tt|8}} | Conceal ''or'' hide | Not widely supported. |- | {{tt|9}} | [[Strikethrough|Crossed-out]], ''or'' strike | Characters legible but marked as if for deletion. Not supported in Terminal.app. |- | {{tt|10}} | Primary (default) font | |- | {{tt|11β19}} | Alternative font | Select alternative font {{math|''n'' β 10}} |- | {{tt|20}} | [[Fraktur]] (Gothic) | Rarely supported |- | {{tt|21}} | Doubly underlined; or: not bold | Double-underline per ECMA-48,<ref name="ECMA-48" />{{Rp|8.3.117}} but instead disables bold intensity on several terminals, including in the [[Linux kernel]]'s [[Linux console|console]] before version 4.17.<ref>{{cite web |url=https://man7.org/linux/man-pages/man4/console_codes.4.html |title=console_codes(4) |work=Linux Programmer's Manual |publisher=Linux [[man (Unix)|man-pages]] project |version=5.10}}</ref> |- | {{tt|22}} | Normal intensity | Neither bold nor faint; color changes where intensity is implemented as such. |- | {{tt|23}} | Neither italic, nor blackletter | |- | {{tt|24}} | Not underlined | Neither singly nor doubly underlined |- | {{tt|25}} | Not blinking |Turn blinking off |- | {{tt|26}} | Proportional spacing | [[ITU T.61]] and T.416, not known to be used on terminals |- | {{tt|27}} | Not reversed | |- | {{tt|28}} | Reveal | Not concealed |- | {{tt|29}} | Not crossed out | |- | {{tt|30β37}} | Set foreground [[#3-bit and 4-bit|color]] | |- | {{tt|38}} | Set foreground [[#8-bit|color]] | [[#8-bit|Next arguments are {{code|5;n}} or {{code|2;r;g;b}}]] |- | {{tt|39}} | Default foreground color | Implementation defined (according to standard) |- | {{tt|40β47}} | Set background [[#3-bit and 4-bit|color]] | |- | {{tt|48}} | Set background [[#8-bit|color]] | [[#8-bit|Next arguments are {{code|5;n}} or {{code|2;r;g;b}}]] |- | {{tt|49}} | Default background color | Implementation defined (according to standard) |- | {{tt|50}} | Disable proportional spacing | T.61 and T.416 |- | {{tt|51}} | Framed | rowspan=2| Implemented as "[[Variation Selectors (Unicode block)|emoji variation selector]]" in mintty.<ref name="mintty">{{cite web |title=mintty/mintty: Text attributes and rendering |url=https://github.com/mintty/mintty/wiki/Tips#text-attributes-and-rendering |website=GitHub |language=en}}</ref> |- | {{tt|52}} | Encircled |- | {{tt|53}} | Overlined | Not supported in Terminal.app |- | {{tt|54}} | Neither framed nor encircled | |- | {{tt|55}} | Not overlined | |- | {{tt|58}} | Set underline [[#8-bit|color]] | Not in standard; implemented in Kitty, VTE, mintty, and iTerm2.<ref name=color-u/><ref name=color-u-kitty-spec/> [[#8-bit|Next arguments are {{code|5;n}} or {{code|2;r;g;b}}]]. |- | {{tt|59}} | Default underline color | Not in standard; implemented in Kitty, VTE, mintty, and iTerm2.<ref name=color-u/><ref name=color-u-kitty-spec/> |- | {{tt|60}} | Ideogram underline or right side line | rowspan="5"| Rarely supported |- | {{tt|61}} | Ideogram double underline, ''or'' double line on the right side |- | {{tt|62}} | Ideogram overline or left side line |- | {{tt|63}} | Ideogram double overline, ''or'' double line on the left side |- | {{tt|64}} | Ideogram stress marking |- | {{tt|65}} | No ideogram attributes | Reset the effects of all of {{code|60}}β{{code|64}} |- | {{tt|73}} | Superscript | rowspan=3| Implemented only in mintty<ref name="mintty"/> |- | {{tt|74}} | Subscript |- | {{tt|75}} | Neither superscript nor subscript |- | {{tt|90β97}} | Set bright foreground color | rowspan=2| Not in standard; originally implemented by aixterm<ref name="xtc"/> |- | {{tt|{{nobr|100β107}}}} | Set bright background color |} <!-- SGR 9x and 10x are not defined in ISO 6429, etc. They were defined for IBM's aixterm, and are used in xterm. The names given for the SGR codes are not normative from the ISO/IEC 6429, nor ECMA 48, nor ANSI X3.64. Rather, they are subjectively descriptive. Room for improvement. --> === {{anchor|colors}} Colors === ==== 3-bit and 4-bit ==== The original specification only had 8 colors, and just gave them names. The SGR parameters 30β37 selected the foreground color, while 40β47 selected the background. Quite a few terminals implemented "bold" (SGR code 1) as a brighter color rather than a different font, thus providing 8 additional foreground colors. Usually you could not get these as background colors, though sometimes inverse video (SGR code 7) would allow that. Examples: to get black letters on white background use {{code|ESC[30;47m}}, to get red use {{code|ESC[31m}}, to get bright red use {{code|ESC[1;31m}}. To reset colors to their defaults, use {{code|ESC[39;49m}} (not supported on some terminals), or reset all attributes with {{code|ESC[0m}}. Later terminals added the ability to directly specify the "bright" colors with 90β97 and 100β107. The chart below shows a few examples of how VGA standard and modern [[terminal emulator]]s translate the 4-bit color codes into 24-bit color codes. <div style="display: flex; width: 100%; overflow-x: auto"> {| class="wikitable" |- ! {{abbr|FG|Foreground}} ! {{abbr|BG|Background}} ! Name ! VGA{{ efn | Typical colors that are used when booting PCs and leaving them in text mode, which used a 16-entry color table. The colors are different in the EGA/VGA graphic modes. }} ! [[Windows Console|Windows XP<br/>Console]]{{ efn | Seen in Windows XP through Windows 8.1 }} ! [[Windows PowerShell|Windows<br/>PowerShell&<br/>1.0β6.0]]{{ efn | PowerShell's default shortcut [[.lnk]], unchanged for over a decade, remaps yellow and magenta to give PowerShell distinctive foreground/background colors compared to the Command Prompt.<ref>{{Cite web |title=default shortcut on Windows remaps ANSI colors 35,36 Β· Issue #4266 Β· PowerShell/PowerShell |url=https://github.com/PowerShell/PowerShell/issues/4266 |access-date=2022-12-21 |website=GitHub |language=en}}</ref> PowerShell 7 is unaffected.}} ! [[Visual Studio Code]]{{efn|Debug console, "Dark+" theme}} ! [[Windows Console|Windows 10<br/>Console]]{{efn | Campbell theme, used as of Windows 10 version 1709.}} ! [[Terminal (macOS)|Terminal.app]] ! [[PuTTY]] ! [[mIRC]] ! [[xterm]] ! [[Ubuntu (operating system)|Ubuntu]]{{efn | For virtual terminals, from /etc/vtrgb.}} !Eclipse Terminal |- | {{tt|30}} || {{tt|40}} || Black | colspan="4" style="background: #000; color: white" | 0,{{nnbsp}}0,{{nnbsp}}0 | style="background: #0c0c0c; color: white" | 12,{{nnbsp}}12,{{nnbsp}}12 | colspan="4" style="background: #000; color: white" | 0,{{nnbsp}}0,{{nnbsp}}0 | style="background: #010101; color: white" | 1,{{nnbsp}}1,{{nnbsp}}1 | style="background: #000; color: white" | 0,{{nnbsp}}0,{{nnbsp}}0 |- | {{tt|31}} || {{tt|41}} || Red | style="background: #AA0000; color: white" | 170,{{nnbsp}}0,{{nnbsp}}0 | colspan="2" style="background: #800000; color: white" | 128,{{nnbsp}}0,{{nnbsp}}0 | style="background: #cd3131; color: white" | 205, 49, 49 | style="background: #c50f1f; color: white" | 197,{{nnbsp}}15,{{nnbsp}}31 | style="background: #990000; color: white" | 153,{{nnbsp}}0,{{nnbsp}}0 | style="background: #bb0000; color: white" | 187,{{nnbsp}}0,{{nnbsp}}0 | style="background: #7f0000; color: white" | 127,{{nnbsp}}0,{{nnbsp}}0 | style="background: #cd0000; color: white" | 205,{{nnbsp}}0,{{nnbsp}}0 | style="background: #de382b; color: white" | 222,{{nnbsp}}56,{{nnbsp}}43 | style="background: #cd0000; color: white" | 205,{{nnbsp}}0,{{nnbsp}}0 |- | {{tt|32}} || {{tt|42}} || Green | style="background: #00AA00; color: white" | 0,{{nnbsp}}170,{{nnbsp}}0 | colspan="2" style="background: #008000; color: white" | 0,{{nnbsp}}128,{{nnbsp}}0 | style="background: #0dbc79; color: white" | 13, 188, 121 | style="background: #13a10e; color: white" | 19,{{nnbsp}}161,{{nnbsp}}14 | style="background: #00A600; color: white" | 0,{{nnbsp}}166,{{nnbsp}}0 | style="background: #00bb00; color: white" | 0,{{nnbsp}}187,{{nnbsp}}0 | style="background: #009300; color: white" | 0,{{nnbsp}}147,{{nnbsp}}0 | style="background: #00cd00; color: white" | 0,{{nnbsp}}205,{{nnbsp}}0 | style="background: #39b54a; color: black" | 57,{{nnbsp}}181,{{nnbsp}}74 | style="background: #00cd00; color: white" | 0,{{nnbsp}}205,{{nnbsp}}0 |- | {{tt|33}} || {{tt|43}} || Yellow | style="background: #AA5500; color: white" | 170,{{nnbsp}}85,{{nnbsp}}0{{ efn | On terminals based on [[Color Graphics Adapter|CGA]] compatible hardware, such as ANSI.SYS running on DOS, this normal intensity foreground color is rendered as orange. CGA [[Color Graphics Adapter#With an RGBI monitor|RGBI]] monitors contained hardware to modify the dark yellow color to an orange/brown color by reducing the green component<ref>{{cite web|url=https://int10h.org/blog/2022/06/ibm-5153-color-true-cga-palette/|title=The IBM 5153's True CGA Palette and Color Output|publisher=VileR|date=2022-06-11|access-date=2024-05-18}}</ref> }} | style="background: #808000; color: white" | 128,{{nnbsp}}128,{{nnbsp}}0 | style="background: #eeedf0; color: black" | 238,{{nnbsp}}237,{{nnbsp}}240 | style="background: #e5e510; color: black" | 229, 229, 16 | style="background: #c19c00; color: white" | 193,{{nnbsp}}156,{{nnbsp}}0 | style="background: #999900; color: white" | 153,{{nnbsp}}153,{{nnbsp}}0 | style="background: #bbbb00; color: black" | 187,{{nnbsp}}187,{{nnbsp}}0 | style="background: #fc7f00; color: white" | 252,{{nnbsp}}127,{{nnbsp}}0 | style="background: #cdcd00; color: black" | 205,{{nnbsp}}205,{{nnbsp}}0 | style="background: #ffc706; color: black" | 255,{{nnbsp}}199,{{nnbsp}}6 | style="background: #cdcd00; color: black" | 205,{{nnbsp}}205,{{nnbsp}}0 |- | {{tt|34}} || {{tt|44}} || Blue | style="background: #0000AA; color: white" | 0,{{nnbsp}}0,{{nnbsp}}170 | colspan="2" style="background: #000080; color: white" | 0,{{nnbsp}}0,{{nnbsp}}128 | style="background: #2472c8; color: white" | 36, 114, 200 | style="background: #0037da; color: white" | 0,{{nnbsp}}55,{{nnbsp}}218 | style="background: #0000B2; color: white" | 0,{{nnbsp}}0,{{nnbsp}}178 | style="background: #0000bb; color: white" | 0,{{nnbsp}}0,{{nnbsp}}187 | style="background: #00007f; color: white" | 0,{{nnbsp}}0,{{nnbsp}}127 | style="background: #0000ee; color: white" | 0,{{nnbsp}}0,{{nnbsp}}238<ref>Changed from 0,{{nnbsp}}0,{{nnbsp}}205 in July 2004 {{cite web |url=http://invisible-island.net/xterm/xterm.log.html#xterm_192 |title=Patch #192 β 2004/7/12 β XFree86 4.4.99.9}}</ref> | style="background: #006fb8; color: white" | 0,{{nnbsp}}111,{{nnbsp}}184 | style="background: #0000ee; color: white" | 0,{{nnbsp}}0,{{nnbsp}}238 |- | {{tt|35}} || {{tt|45}} || Magenta | style="background: #AA00AA; color: white" | 170,{{nnbsp}}0,{{nnbsp}}170 | style="background: #800080; color: white" | 128,{{nnbsp}}0,{{nnbsp}}128 | style="background: #012456; color: white" | 1,{{nnbsp}}36,{{nnbsp}}86 | style="background: #bc3fbc; color: white" | 188, 63, 188 | style="background: #881798; color: white" | 136,{{nnbsp}}23,{{nnbsp}}152 | style="background: #B200B2; color: white" | 178,{{nnbsp}}0,{{nnbsp}}178 | style="background: #bb00bb; color: white" | 187,{{nnbsp}}0,{{nnbsp}}187 | style="background: #9c009c; color: white" | 156,{{nnbsp}}0,{{nnbsp}}156 | style="background: #cd00cd; color: white" | 205,{{nnbsp}}0,{{nnbsp}}205 | style="background: #762671; color: white" | 118,{{nnbsp}}38,{{nnbsp}}113 | style="background: #cd00cd; color: white" | 205,{{nnbsp}}0,{{nnbsp}}205 |- | {{tt|36}} || {{tt|46}} || Cyan | style="background: #00AAAA; color: white" | 0,{{nnbsp}}170,{{nnbsp}}170 | colspan="2" style="background: #008080; color: white" | 0,{{nnbsp}}128,{{nnbsp}}128 | style="background: #11a8cd; color: white" | 17, 168, 205 | style="background: #3a96dd; color: white" | 58,{{nnbsp}}150,{{nnbsp}}221 | style="background: #00A6B2; color: white" | 0,{{nnbsp}}166,{{nnbsp}}178 | style="background: #00bbbb; color: black" | 0,{{nnbsp}}187,{{nnbsp}}187 | style="background: #009393; color: white" | 0,{{nnbsp}}147,{{nnbsp}}147 | style="background: #00cdcd; color: black" | 0,{{nnbsp}}205,{{nnbsp}}205 | style="background: #2cb5e9; color: black" | 44,{{nnbsp}}181,{{nnbsp}}233 | style="background: #00cdcd; color: black" | 0,{{nnbsp}}205,{{nnbsp}}205 |- | {{tt|37}} || {{tt|47}} || White | style="background: #AAAAAA; color: black" | 170,{{nnbsp}}170,{{nnbsp}}170 | colspan="2" style="background: #c0c0c0; color: black" | 192,{{nnbsp}}192,{{nnbsp}}192 | style="background: #e5e5e5; color: black" | 229, 229, 229 | style="background: #cccccc; color: black" | 204,{{nnbsp}}204,{{nnbsp}}204 | style="background: #BFBFBF; color: black" | 191,{{nnbsp}}191,{{nnbsp}}191 | style="background: #bbbbbb; color: black" | 187,{{nnbsp}}187,{{nnbsp}}187 | style="background: #d2d2d2; color: black" | 210,{{nnbsp}}210,{{nnbsp}}210 | style="background: #e5e5e5; color: black" | 229,{{nnbsp}}229,{{nnbsp}}229 | style="background: #cccccc; color: black" | 204,{{nnbsp}}204,{{nnbsp}}204 | style="background: #e5e5e5; color: black" | 229,{{nnbsp}}229,{{nnbsp}}229 |- | {{tt|90}} || {{tt|100}} || {{nobr|Bright Black (Gray)}} | style="background: #555555; color: white" | 85,{{nnbsp}}85,{{nnbsp}}85 | colspan="2" style="background: #808080; color: black" | 128,{{nnbsp}}128,{{nnbsp}}128 | style="background: #666666; color: white" | 102, 102, 102 | style="background: #767676; color: white" | 118,{{nnbsp}}118,{{nnbsp}}118 | style="background: #666666; color: white" | 102,{{nnbsp}}102,{{nnbsp}}102 | style="background: #555555; color: white" | 85,{{nnbsp}}85,{{nnbsp}}85 | style="background: #7f7f7f; color: white" | 127,{{nnbsp}}127,{{nnbsp}}127 | style="background: #7f7f7f; color: white" | 127,{{nnbsp}}127,{{nnbsp}}127 | style="background: #808080; color: black" | 128,{{nnbsp}}128,{{nnbsp}}128 | style="background: #000000; color: white" | 0,{{nnbsp}}0,{{nnbsp}}0 |- | {{tt|91}} || {{tt|101}} || Bright Red | style="background: #FF5555; color: white" | 255,{{nnbsp}}85,{{nnbsp}}85 | colspan="2" style="background: #ff0000; color: white" | 255,{{nnbsp}}0,{{nnbsp}}0 | style="background: #f14c4c; color: white" | 241, 76, 76 | style="background: #e74856; color: white" | 231,{{nnbsp}}72,{{nnbsp}}86 | style="background: #E60000; color: white" | 230,{{nnbsp}}0,{{nnbsp}}0 | style="background: #ff5555; color: white" | 255,{{nnbsp}}85,{{nnbsp}}85 | colspan="4" style="background: #ff0000; color: white" | 255,{{nnbsp}}0,{{nnbsp}}0 |- | {{tt|92}} || {{tt|102}} || Bright Green | style="background: #55FF55; color: black" | 85,{{nnbsp}}255,{{nnbsp}}85 | colspan="2" style="background: #00ff00; color: black" | 0,{{nnbsp}}255,{{nnbsp}}0 | style="background: #23d18b; color: white" | 35, 209, 139 | style="background: #16c60c; color: black" | 22,{{nnbsp}}198,{{nnbsp}}12 | style="background: #00D900; color: black" | 0,{{nnbsp}}217,{{nnbsp}}0 | style="background: #55ff55; color: black" | 85,{{nnbsp}}255,{{nnbsp}}85 | style="background: #00fc00; color: black" | 0,{{nnbsp}}252,{{nnbsp}}0 | colspan="3" style="background: #00ff00; color: black" | 0,{{nnbsp}}255,{{nnbsp}}0 |- | {{tt|93}} || {{tt|103}} || Bright Yellow | style="background: #FFFF55; color: black" | 255,{{nnbsp}}255,{{nnbsp}}85 | colspan="2" style="background: #ffff00; color: black" | 255,{{nnbsp}}255,{{nnbsp}}0 | style="background: #f5f543; color: black" | 245, 245, 67 | style="background: #f9f1a5; color: black" | 249,{{nnbsp}}241,{{nnbsp}}165 | style="background: #E5E500; color: black" | 230,{{nnbsp}}230,{{nnbsp}}0 | style="background: #ffff55; color: black" | 255,{{nnbsp}}255,{{nnbsp}}85 | colspan="4" style="background: #ffff00; color: black" | 255,{{nnbsp}}255,{{nnbsp}}0 |- | {{tt|94}} || {{tt|104}} || Bright Blue | style="background: #5555FF; color: white" | 85,{{nnbsp}}85,{{nnbsp}}255 | colspan="2" style="background: #0000ff; color: white" | 0,{{nnbsp}}0,{{nnbsp}}255 | style="background: #3b8eea; color: white" | 59, 142, 234 | style="background: #3b78ff; color: white" | 59,{{nnbsp}}120,{{nnbsp}}255 | style="background: #0000FF; color: white" | 0,{{nnbsp}}0,{{nnbsp}}255 | style="background: #5555ff; color: white" | 85,{{nnbsp}}85,{{nnbsp}}255 | style="background: #0000fc; color: white" | 0,{{nnbsp}}0,{{nnbsp}}252 | style="background: #5c5cff; color: white" | 92,{{nnbsp}}92,{{nnbsp}}255<ref>Changed from 0,{{nnbsp}}0,{{nnbsp}}255 in July 2004 {{cite web |url=http://invisible-island.net/xterm/xterm.log.html#xterm_192 |title=Patch #192 β 2004/7/12 β XFree86 4.4.99.9}}</ref> | style="background: #0000ff; color: white" | 0,{{nnbsp}}0,{{nnbsp}}255 | style="background: #5c5cff; color: white" | 92,{{nnbsp}}92,{{nnbsp}}255 |- | {{tt|95}} || {{tt|105}} || Bright Magenta | style="background: #FF55FF; color: black" | 255,{{nnbsp}}85,{{nnbsp}}255 | colspan="2" style="background: #ff00ff; color: white" | 255,{{nnbsp}}0,{{nnbsp}}255 | style="background: #d670d6; color: white" | 214, 112, 214 | style="background: #b4009e; color: white" | 180,{{nnbsp}}0,{{nnbsp}}158 | style="background: #E600E6; color: white" | 230,{{nnbsp}}0,{{nnbsp}}230 | style="background: #ff55ff; color: white" | 255,{{nnbsp}}85,{{nnbsp}}255 | colspan="4" style="background: #ff00ff; color: white" | 255,{{nnbsp}}0,{{nnbsp}}255 |- | {{tt|96}} || {{tt|106}} || Bright Cyan | style="background: #55FFFF; color: black" | 85,{{nnbsp}}255,{{nnbsp}}255 | colspan="2" style="background: #00ffff; color: black" | 0,{{nnbsp}}255,{{nnbsp}}255 | style="background: #29b8dB; color: white" | 41, 184, 219 | style="background: #61d6d6; color: black" | 97,{{nnbsp}}214,{{nnbsp}}214 | style="background: #00E6E6; color: black" | 0,{{nnbsp}}230,{{nnbsp}}230 | style="background: #55ffff; color: black" | 85,{{nnbsp}}255,{{nnbsp}}255 | colspan="4" style="background: #00ffff; color: black" | 0,{{nnbsp}}255,{{nnbsp}}255 |- | {{tt|97}} || {{tt|107}} || Bright White | colspan="3" style="background: #ffffff; color: black" | 255,{{nnbsp}}255,{{nnbsp}}255 | style="background: #e5e5e5; color: black" | {{nobr|229, 229, 229}} | style="background: #f2f2f2; color: black" | 242,{{nnbsp}}242,{{nnbsp}}242 | style="background: #E6E6E6; color: black" | 230,{{nnbsp}}230,{{nnbsp}}230 | colspan="5" style="background: #ffffff; color: black" | 255,{{nnbsp}}255,{{nnbsp}}255 |} </div> ==== 8-bit ==== {{seealso|Web colors#Web-safe colors}} As [[8-bit color|256-color]] lookup tables became common on graphic cards, escape sequences were added to select from a pre-defined set of 256 colors:<ref>{{cite web |url=https://invisible-island.net/xterm/xterm.faq.html#color_by_number |title=XTerm FAQ: Can I set a color by its number? |author-first=Thomas E. |author-last=Dickey |accessdate=March 28, 2025}}</ref> ESC[38;5;{{angbr|n}}m Select foreground color where n is a number from the table below ESC[48;5;{{angbr|n}}m Select background color 0- 7: standard colors (as in ESC [ 30β37 m) 8- 15: high intensity colors (as in ESC [ 90β97 m) 16-231: 6 Γ 6 Γ 6 cube (216 colors): 16 + 36 Γ r + 6 Γ g + b (0 β€ r, g, b β€ 5) 232-255: grayscale from dark to light in 24 steps The colors displayed by these values vary across terminal/emulator implementations as the recognized ECMA-48 and ITU's T.416 specifications do not define a specific color palette for this lookup table. While it is common to use the above formula for the color palette, in particular the algorithm and choice of colors for the 16-231 cube values differs between implementations. The color palette and algorithm used by XTerm is specified below as a sample.<ref name="ECMA-48" /><ref name="T.416" /> The [[ITU]]'s T.416 Information technology - Open Document Architecture (ODA) and interchange format: Character content architectures<ref name="T.416">{{cite web |url=https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-T.416-199303-I!!PDF-E&type=items |title=T.416 Information technology - Open Document Architecture (ODA) and interchange format: Character content architectures}}</ref> uses ":" as separator characters instead: ESC[38:5:{{angbr|n}}m Select foreground color where n is a number from the table below ESC[48:5:{{angbr|n}}m Select background color<!-- def fg(triad): return 'ffffff' if (triad[2:4] < 'a0') else '000000' standards = ('000000 800000 008000 808000 000080 800080 008080 c0c0c0 ' + '808080 ff0000 00ff00 ffff00 0000ff ff00ff 00ffff ffffff').split(' ') rgbs = '00 5f 87 af d7 ff'.split(' ') greys = '08 12 1c 26 30 3a 44 4e 58 62 6c 76 80 8a 94 9e a8 b2 bc c6 d0 da e4 ee'.split(' ') fgs = '000000 ffffff'.split(' ') code = 0 outs = [[] for i in range(3)] out = '\n| style="color:#%s;background:#%s;" title="#%s" |%s' for i in range(len(standards)): if (i == len(standards) / 2.0): outs[0].append('\n| style="width:1em;"| ') triad = standards[i] outs[0].append(out % (fgs[i < len(standards) / 2], triad, triad, code if (code > 9) else ' %d ' % code)) code += 1 for r in range(len(rgbs)): for g in range(len(rgbs)): for b in range(len(rgbs)): triad = rgbs[r] + rgbs[g] + rgbs[b] outs[1].append(out % (fgs[g < len(rgbs) / 2], triad, triad, code)) code += 1 outs[1].append('\n|-\n') for i in range(len(greys)): triad = greys[i] * 3 outs[2].append(out % (fgs[i < len(greys) / 2], triad, triad, code)) code += 1 file_out = open(__file__[:__file__.rfind('.')] + '.htm', 'w') file_out.write('''\ {| table class="collapsible" style="text-align:center;font-size:80%%;width:100%%;background:#f6f6f6;cursor:default;" cellpadding="0" cellspacing="1" |- ! colspan="36" | 256-color mode β foreground: ESC[38;5;#m background: ESC[48;5;#m |- | colspan="18" | Standard colors | colspan="18" | High-intensity colors |- | colspan="36" | {| style="width:100%%;text-align:center;font-weight:bold;" |- %s |- |} |- | colspan="36" | 216 colors |- %s |- | colspan="36" | Grayscale colors |- | colspan="36" | {| style="width:100%%;text-align:center;font-weight:bold;" |- %s |- |} |}''' % (''.join(outs[0]), ''.join(outs[1]), ''.join(outs[2]))) file_out.close() --> {{anchor|256_color_table}} {| class="collapsible" style="text-align:center;font-size:80%;width:100%;background:#f6f6f6;cursor:default;" cellpadding="0" cellspacing="1" |- ! colspan="36" | 256-color mode β foreground: ESC[38;5;#m background: ESC[48;5;#m |- | colspan="18" | Standard colors | colspan="18" | High-intensity colors |- | colspan="36" | {| style="width:100%;text-align:center;font-weight:bold;" |- | style="color:#ffffff;background:#000000;" title="#000000" | 0 | style="color:#ffffff;background:#800000;" title="#800000" | 1 | style="color:#ffffff;background:#008000;" title="#008000" | 2 | style="color:#ffffff;background:#808000;" title="#808000" | 3 | style="color:#ffffff;background:#000080;" title="#000080" | 4 | style="color:#ffffff;background:#800080;" title="#800080" | 5 | style="color:#ffffff;background:#008080;" title="#008080" | 6 | style="color:#ffffff;background:#c0c0c0;" title="#c0c0c0" | 7 | style="width:1em;" | | style="color:#000000;background:#808080;" title="#808080" | 8 | style="color:#000000;background:#ff0000;" title="#ff0000" | 9 | style="color:#000000;background:#00ff00;" title="#00ff00" |10 | style="color:#000000;background:#ffff00;" title="#ffff00" |11 | style="color:#000000;background:#0000ff;" title="#0000ff" |12 | style="color:#000000;background:#ff00ff;" title="#ff00ff" |13 | style="color:#000000;background:#00ffff;" title="#00ffff" |14 | style="color:#000000;background:#ffffff;" title="#ffffff" |15 |} |- | colspan="36" |216 colors |- | style="color:#ffffff;background:#000000;" title="#000000" |16 | style="color:#ffffff;background:#00005f;" title="#00005f" |17 | style="color:#ffffff;background:#000087;" title="#000087" |18 | style="color:#ffffff;background:#0000af;" title="#0000af" |19 | style="color:#ffffff;background:#0000d7;" title="#0000d7" |20 | style="color:#ffffff;background:#0000ff;" title="#0000ff" |21 | style="color:#ffffff;background:#005f00;" title="#005f00" |22 | style="color:#ffffff;background:#005f5f;" title="#005f5f" |23 | style="color:#ffffff;background:#005f87;" title="#005f87" |24 | style="color:#ffffff;background:#005faf;" title="#005faf" |25 | style="color:#ffffff;background:#005fd7;" title="#005fd7" |26 | style="color:#ffffff;background:#005fff;" title="#005fff" |27 | style="color:#ffffff;background:#008700;" title="#008700" |28 | style="color:#ffffff;background:#00875f;" title="#00875f" |29 | style="color:#ffffff;background:#008787;" title="#008787" |30 | style="color:#ffffff;background:#0087af;" title="#0087af" |31 | style="color:#ffffff;background:#0087d7;" title="#0087d7" |32 | style="color:#ffffff;background:#0087ff;" title="#0087ff" |33 | style="color:#000000;background:#00af00;" title="#00af00" |34 | style="color:#000000;background:#00af5f;" title="#00af5f" |35 | style="color:#000000;background:#00af87;" title="#00af87" |36 | style="color:#000000;background:#00afaf;" title="#00afaf" |37 | style="color:#000000;background:#00afd7;" title="#00afd7" |38 | style="color:#000000;background:#00afff;" title="#00afff" |39 | style="color:#000000;background:#00d700;" title="#00d700" |40 | style="color:#000000;background:#00d75f;" title="#00d75f" |41 | style="color:#000000;background:#00d787;" title="#00d787" |42 | style="color:#000000;background:#00d7af;" title="#00d7af" |43 | style="color:#000000;background:#00d7d7;" title="#00d7d7" |44 | style="color:#000000;background:#00d7ff;" title="#00d7ff" |45 | style="color:#000000;background:#00ff00;" title="#00ff00" |46 | style="color:#000000;background:#00ff5f;" title="#00ff5f" |47 | style="color:#000000;background:#00ff87;" title="#00ff87" |48 | style="color:#000000;background:#00ffaf;" title="#00ffaf" |49 | style="color:#000000;background:#00ffd7;" title="#00ffd7" |50 | style="color:#000000;background:#00ffff;" title="#00ffff" |51 |- | style="color:#ffffff;background:#5f0000;" title="#5f0000" |52 | style="color:#ffffff;background:#5f005f;" title="#5f005f" |53 | style="color:#ffffff;background:#5f0087;" title="#5f0087" |54 | style="color:#ffffff;background:#5f00af;" title="#5f00af" |55 | style="color:#ffffff;background:#5f00d7;" title="#5f00d7" |56 | style="color:#ffffff;background:#5f00ff;" title="#5f00ff" |57 | style="color:#ffffff;background:#5f5f00;" title="#5f5f00" |58 | style="color:#ffffff;background:#5f5f5f;" title="#5f5f5f" |59 | style="color:#ffffff;background:#5f5f87;" title="#5f5f87" |60 | style="color:#ffffff;background:#5f5faf;" title="#5f5faf" |61 | style="color:#ffffff;background:#5f5fd7;" title="#5f5fd7" |62 | style="color:#ffffff;background:#5f5fff;" title="#5f5fff" |63 | style="color:#ffffff;background:#5f8700;" title="#5f8700" |64 | style="color:#ffffff;background:#5f875f;" title="#5f875f" |65 | style="color:#ffffff;background:#5f8787;" title="#5f8787" |66 | style="color:#ffffff;background:#5f87af;" title="#5f87af" |67 | style="color:#ffffff;background:#5f87d7;" title="#5f87d7" |68 | style="color:#ffffff;background:#5f87ff;" title="#5f87ff" |69 | style="color:#000000;background:#5faf00;" title="#5faf00" |70 | style="color:#000000;background:#5faf5f;" title="#5faf5f" |71 | style="color:#000000;background:#5faf87;" title="#5faf87" |72 | style="color:#000000;background:#5fafaf;" title="#5fafaf" |73 | style="color:#000000;background:#5fafd7;" title="#5fafd7" |74 | style="color:#000000;background:#5fafff;" title="#5fafff" |75 | style="color:#000000;background:#5fd700;" title="#5fd700" |76 | style="color:#000000;background:#5fd75f;" title="#5fd75f" |77 | style="color:#000000;background:#5fd787;" title="#5fd787" |78 | style="color:#000000;background:#5fd7af;" title="#5fd7af" |79 | style="color:#000000;background:#5fd7d7;" title="#5fd7d7" |80 | style="color:#000000;background:#5fd7ff;" title="#5fd7ff" |81 | style="color:#000000;background:#5fff00;" title="#5fff00" |82 | style="color:#000000;background:#5fff5f;" title="#5fff5f" |83 | style="color:#000000;background:#5fff87;" title="#5fff87" |84 | style="color:#000000;background:#5fffaf;" title="#5fffaf" |85 | style="color:#000000;background:#5fffd7;" title="#5fffd7" |86 | style="color:#000000;background:#5fffff;" title="#5fffff" |87 |- | style="color:#ffffff;background:#870000;" title="#870000" |88 | style="color:#ffffff;background:#87005f;" title="#87005f" |89 | style="color:#ffffff;background:#870087;" title="#870087" |90 | style="color:#ffffff;background:#8700af;" title="#8700af" |91 | style="color:#ffffff;background:#8700d7;" title="#8700d7" |92 | style="color:#ffffff;background:#8700ff;" title="#8700ff" |93 | style="color:#ffffff;background:#875f00;" title="#875f00" |94 | style="color:#ffffff;background:#875f5f;" title="#875f5f" |95 | style="color:#ffffff;background:#875f87;" title="#875f87" |96 | style="color:#ffffff;background:#875faf;" title="#875faf" |97 | style="color:#ffffff;background:#875fd7;" title="#875fd7" |98 | style="color:#ffffff;background:#875fff;" title="#875fff" |99 | style="color:#ffffff;background:#878700;" title="#878700" |100 | style="color:#ffffff;background:#87875f;" title="#87875f" |101 | style="color:#ffffff;background:#878787;" title="#878787" |102 | style="color:#ffffff;background:#8787af;" title="#8787af" |103 | style="color:#ffffff;background:#8787d7;" title="#8787d7" |104 | style="color:#ffffff;background:#8787ff;" title="#8787ff" |105 | style="color:#000000;background:#87af00;" title="#87af00" |106 | style="color:#000000;background:#87af5f;" title="#87af5f" |107 | style="color:#000000;background:#87af87;" title="#87af87" |108 | style="color:#000000;background:#87afaf;" title="#87afaf" |109 | style="color:#000000;background:#87afd7;" title="#87afd7" |110 | style="color:#000000;background:#87afff;" title="#87afff" |111 | style="color:#000000;background:#87d700;" title="#87d700" |112 | style="color:#000000;background:#87d75f;" title="#87d75f" |113 | style="color:#000000;background:#87d787;" title="#87d787" |114 | style="color:#000000;background:#87d7af;" title="#87d7af" |115 | style="color:#000000;background:#87d7d7;" title="#87d7d7" |116 | style="color:#000000;background:#87d7ff;" title="#87d7ff" |117 | style="color:#000000;background:#87ff00;" title="#87ff00" |118 | style="color:#000000;background:#87ff5f;" title="#87ff5f" |119 | style="color:#000000;background:#87ff87;" title="#87ff87" |120 | style="color:#000000;background:#87ffaf;" title="#87ffaf" |121 | style="color:#000000;background:#87ffd7;" title="#87ffd7" |122 | style="color:#000000;background:#87ffff;" title="#87ffff" |123 |- | style="color:#ffffff;background:#af0000;" title="#af0000" |124 | style="color:#ffffff;background:#af005f;" title="#af005f" |125 | style="color:#ffffff;background:#af0087;" title="#af0087" |126 | style="color:#ffffff;background:#af00af;" title="#af00af" |127 | style="color:#ffffff;background:#af00d7;" title="#af00d7" |128 | style="color:#ffffff;background:#af00ff;" title="#af00ff" |129 | style="color:#ffffff;background:#af5f00;" title="#af5f00" |130 | style="color:#ffffff;background:#af5f5f;" title="#af5f5f" |131 | style="color:#ffffff;background:#af5f87;" title="#af5f87" |132 | style="color:#ffffff;background:#af5faf;" title="#af5faf" |133 | style="color:#ffffff;background:#af5fd7;" title="#af5fd7" |134 | style="color:#ffffff;background:#af5fff;" title="#af5fff" |135 | style="color:#ffffff;background:#af8700;" title="#af8700" |136 | style="color:#ffffff;background:#af875f;" title="#af875f" |137 | style="color:#ffffff;background:#af8787;" title="#af8787" |138 | style="color:#ffffff;background:#af87af;" title="#af87af" |139 | style="color:#ffffff;background:#af87d7;" title="#af87d7" |140 | style="color:#ffffff;background:#af87ff;" title="#af87ff" |141 | style="color:#000000;background:#afaf00;" title="#afaf00" |142 | style="color:#000000;background:#afaf5f;" title="#afaf5f" |143 | style="color:#000000;background:#afaf87;" title="#afaf87" |144 | style="color:#000000;background:#afafaf;" title="#afafaf" |145 | style="color:#000000;background:#afafd7;" title="#afafd7" |146 | style="color:#000000;background:#afafff;" title="#afafff" |147 | style="color:#000000;background:#afd700;" title="#afd700" |148 | style="color:#000000;background:#afd75f;" title="#afd75f" |149 | style="color:#000000;background:#afd787;" title="#afd787" |150 | style="color:#000000;background:#afd7af;" title="#afd7af" |151 | style="color:#000000;background:#afd7d7;" title="#afd7d7" |152 | style="color:#000000;background:#afd7ff;" title="#afd7ff" |153 | style="color:#000000;background:#afff00;" title="#afff00" |154 | style="color:#000000;background:#afff5f;" title="#afff5f" |155 | style="color:#000000;background:#afff87;" title="#afff87" |156 | style="color:#000000;background:#afffaf;" title="#afffaf" |157 | style="color:#000000;background:#afffd7;" title="#afffd7" |158 | style="color:#000000;background:#afffff;" title="#afffff" |159 |- | style="color:#ffffff;background:#d70000;" title="#d70000" |160 | style="color:#ffffff;background:#d7005f;" title="#d7005f" |161 | style="color:#ffffff;background:#d70087;" title="#d70087" |162 | style="color:#ffffff;background:#d700af;" title="#d700af" |163 | style="color:#ffffff;background:#d700d7;" title="#d700d7" |164 | style="color:#ffffff;background:#d700ff;" title="#d700ff" |165 | style="color:#ffffff;background:#d75f00;" title="#d75f00" |166 | style="color:#ffffff;background:#d75f5f;" title="#d75f5f" |167 | style="color:#ffffff;background:#d75f87;" title="#d75f87" |168 | style="color:#ffffff;background:#d75faf;" title="#d75faf" |169 | style="color:#ffffff;background:#d75fd7;" title="#d75fd7" |170 | style="color:#ffffff;background:#d75fff;" title="#d75fff" |171 | style="color:#ffffff;background:#d78700;" title="#d78700" |172 | style="color:#ffffff;background:#d7875f;" title="#d7875f" |173 | style="color:#ffffff;background:#d78787;" title="#d78787" |174 | style="color:#ffffff;background:#d787af;" title="#d787af" |175 | style="color:#ffffff;background:#d787d7;" title="#d787d7" |176 | style="color:#ffffff;background:#d787ff;" title="#d787ff" |177 | style="color:#000000;background:#d7af00;" title="#d7af00" |178 | style="color:#000000;background:#d7af5f;" title="#d7af5f" |179 | style="color:#000000;background:#d7af87;" title="#d7af87" |180 | style="color:#000000;background:#d7afaf;" title="#d7afaf" |181 | style="color:#000000;background:#d7afd7;" title="#d7afd7" |182 | style="color:#000000;background:#d7afff;" title="#d7afff" |183 | style="color:#000000;background:#d7d700;" title="#d7d700" |184 | style="color:#000000;background:#d7d75f;" title="#d7d75f" |185 | style="color:#000000;background:#d7d787;" title="#d7d787" |186 | style="color:#000000;background:#d7d7af;" title="#d7d7af" |187 | style="color:#000000;background:#d7d7d7;" title="#d7d7d7" |188 | style="color:#000000;background:#d7d7ff;" title="#d7d7ff" |189 | style="color:#000000;background:#d7ff00;" title="#d7ff00" |190 | style="color:#000000;background:#d7ff5f;" title="#d7ff5f" |191 | style="color:#000000;background:#d7ff87;" title="#d7ff87" |192 | style="color:#000000;background:#d7ffaf;" title="#d7ffaf" |193 | style="color:#000000;background:#d7ffd7;" title="#d7ffd7" |194 | style="color:#000000;background:#d7ffff;" title="#d7ffff" |195 |- | style="color:#ffffff;background:#ff0000;" title="#ff0000" |196 | style="color:#ffffff;background:#ff005f;" title="#ff005f" |197 | style="color:#ffffff;background:#ff0087;" title="#ff0087" |198 | style="color:#ffffff;background:#ff00af;" title="#ff00af" |199 | style="color:#ffffff;background:#ff00d7;" title="#ff00d7" |200 | style="color:#ffffff;background:#ff00ff;" title="#ff00ff" |201 | style="color:#ffffff;background:#ff5f00;" title="#ff5f00" |202 | style="color:#ffffff;background:#ff5f5f;" title="#ff5f5f" |203 | style="color:#ffffff;background:#ff5f87;" title="#ff5f87" |204 | style="color:#ffffff;background:#ff5faf;" title="#ff5faf" |205 | style="color:#ffffff;background:#ff5fd7;" title="#ff5fd7" |206 | style="color:#ffffff;background:#ff5fff;" title="#ff5fff" |207 | style="color:#ffffff;background:#ff8700;" title="#ff8700" |208 | style="color:#ffffff;background:#ff875f;" title="#ff875f" |209 | style="color:#ffffff;background:#ff8787;" title="#ff8787" |210 | style="color:#ffffff;background:#ff87af;" title="#ff87af" |211 | style="color:#ffffff;background:#ff87d7;" title="#ff87d7" |212 | style="color:#ffffff;background:#ff87ff;" title="#ff87ff" |213 | style="color:#000000;background:#ffaf00;" title="#ffaf00" |214 | style="color:#000000;background:#ffaf5f;" title="#ffaf5f" |215 | style="color:#000000;background:#ffaf87;" title="#ffaf87" |216 | style="color:#000000;background:#ffafaf;" title="#ffafaf" |217 | style="color:#000000;background:#ffafd7;" title="#ffafd7" |218 | style="color:#000000;background:#ffafff;" title="#ffafff" |219 | style="color:#000000;background:#ffd700;" title="#ffd700" |220 | style="color:#000000;background:#ffd75f;" title="#ffd75f" |221 | style="color:#000000;background:#ffd787;" title="#ffd787" |222 | style="color:#000000;background:#ffd7af;" title="#ffd7af" |223 | style="color:#000000;background:#ffd7d7;" title="#ffd7d7" |224 | style="color:#000000;background:#ffd7ff;" title="#ffd7ff" |225 | style="color:#000000;background:#ffff00;" title="#ffff00" |226 | style="color:#000000;background:#ffff5f;" title="#ffff5f" |227 | style="color:#000000;background:#ffff87;" title="#ffff87" |228 | style="color:#000000;background:#ffffaf;" title="#ffffaf" |229 | style="color:#000000;background:#ffffd7;" title="#ffffd7" |230 | style="color:#000000;background:#ffffff;" title="#ffffff" |231 |- |- | colspan="36" |Grayscale colors |- | colspan="36" | {| style="width:100%;text-align:center;font-weight:bold;" |- | style="color:#ffffff;background:#080808;" title="#080808" |232 | style="color:#ffffff;background:#121212;" title="#121212" |233 | style="color:#ffffff;background:#1c1c1c;" title="#1c1c1c" |234 | style="color:#ffffff;background:#262626;" title="#262626" |235 | style="color:#ffffff;background:#303030;" title="#303030" |236 | style="color:#ffffff;background:#3a3a3a;" title="#3a3a3a" |237 | style="color:#ffffff;background:#444444;" title="#444444" |238 | style="color:#ffffff;background:#4e4e4e;" title="#4e4e4e" |239 | style="color:#ffffff;background:#585858;" title="#585858" |240 | style="color:#ffffff;background:#626262;" title="#626262" |241 | style="color:#ffffff;background:#6c6c6c;" title="#6c6c6c" |242 | style="color:#ffffff;background:#767676;" title="#767676" |243 | style="color:#000000;background:#808080;" title="#808080" |244 | style="color:#000000;background:#8a8a8a;" title="#8a8a8a" |245 | style="color:#000000;background:#949494;" title="#949494" |246 | style="color:#000000;background:#9e9e9e;" title="#9e9e9e" |247 | style="color:#000000;background:#a8a8a8;" title="#a8a8a8" |248 | style="color:#000000;background:#b2b2b2;" title="#b2b2b2" |249 | style="color:#000000;background:#bcbcbc;" title="#bcbcbc" |250 | style="color:#000000;background:#c6c6c6;" title="#c6c6c6" |251 | style="color:#000000;background:#d0d0d0;" title="#d0d0d0" |252 | style="color:#000000;background:#dadada;" title="#dadada" |253 | style="color:#000000;background:#e4e4e4;" title="#e4e4e4" |254 | style="color:#000000;background:#eeeeee;" title="#eeeeee" |255 |} |} To calculate the RGB Value of a code in the 6 x 6 x 6 color cube, the following code can be used: <syntaxhighlight lang="python" line> # print a list of the 256-color red/green/blue values used by xterm. # # reference: # https://github.com/ThomasDickey/ncurses-snapshots/blob/master/test/xterm-16color.dat # https://github.com/ThomasDickey/xterm-snapshots/blob/master/XTerm-col.ad # https://github.com/ThomasDickey/xterm-snapshots/blob/master/256colres.pl print("colors 0-16 correspond to the ANSI and aixterm naming") for code in range(0, 16): if code > 8: level = 255 elif code == 7: level = 229 else: level = 205 r = 127 if code == 8 else level if (code & 1) != 0 else 92 if code == 12 else 0 g = 127 if code == 8 else level if (code & 2) != 0 else 92 if code == 12 else 0 b = 127 if code == 8 else 238 if code == 4 else level if (code & 4) != 0 else 0 print(f"{code:3d}: {r:02X} {g:02X} {b:02X}") print("colors 16-231 are a 6x6x6 color cube") for red in range(0, 6): for green in range(0, 6): for blue in range(0, 6): code = 16 + (red * 36) + (green * 6) + blue r = red * 40 + 55 if red != 0 else 0 g = green * 40 + 55 if green != 0 else 0 b = blue * 40 + 55 if blue != 0 else 0 print(f"{code:3d}: {r:02X} {g:02X} {b:02X}") print("colors 232-255 are a grayscale ramp, intentionally leaving out black and white") code = 232 for gray in range(0, 24): level = gray * 10 + 8 code = 232 + gray print(f"{code:3d}: {level:02X} {level:02X} {level:02X}") </syntaxhighlight> There has also been a similar but incompatible 88-color encoding using the same escape sequence, seen in {{code|rxvt}} and {{code|xterm-88color}}.<ref>{{cite web |url=https://invisible-island.net/ncurses/ncurses.faq.html#xterm_256color |title=Ncurses FAQ: Why not make "xterm" equated to "xterm-256color"? |author-first=Thomas E. |author-last=Dickey |accessdate=March 28, 2025}}</ref> It uses a 4Γ4Γ4 color cube. ==== 24-bit ==== As "true color" graphic cards with 16 to 24 bits of color became common, applications began to support 24-bit colors. Terminal emulators supporting setting 24-bit foreground and background colors with escape sequences include Xterm,<ref name="xtc"/> KDE's [[Konsole]],<ref>{{cite web |url=https://quickgit.kde.org/?p=konsole.git&a=blob&f=tests%2Fcolor-spaces.pl |title=color-spaces.pl (a copy of 256colors2.pl from xterm dated 1999-07-11) |publisher=KDE |date=2006-12-06 }}{{Dead link|date=June 2020 |bot=InternetArchiveBot |fix-attempted=yes }}</ref><ref>{{cite web |url=https://invent.kde.org/personalizedrefrigerator/konsole/-/blob/master/doc/user/README.moreColors |title=README.moreColors |publisher=KDE |date=2010-04-22 }}</ref> and iTerm, as well as all libvte based terminals,<ref>{{cite web |url=https://bugzilla.gnome.org/show_bug.cgi?id=704449 |title=libvte's bug report and patches: Support for 16 million colors |publisher=GNOME Bugzilla |date=2014-04-04 |access-date=2016-06-05}}</ref> including [[GNOME Terminal]].<ref>{{cite web|url=https://askubuntu.com/questions/512525/how-to-enable-24bit-true-color-support-in-gnome-terminal|title=How to enable 24bit true color support in Gnome terminal?}}</ref> ESC[38;2;{{angbr|r}};{{angbr|g}};{{angbr|b}}m Select RGB foreground color ESC[48;2;{{angbr|r}};{{angbr|g}};{{angbr|b}}m Select RGB background color The syntax is likely based on the [[ITU]]'s T.416 [[Open Document Architecture]] (ODA) and interchange format: Character content architectures,<ref name="T.416"/> which was adopted as ISO/IEC 8613-6 but ended up as a commercial failure.{{cn|date=February 2022}} The ODA version is more elaborate and thus incompatible: * The parameters after the '2' (r, g, and b) are optional and can be left empty. * Semicolons are replaced by colons, as above. * There is a leading "colorspace ID".<ref name="xtc"/> The definition of the colorspace ID is not included in that specification, so it may be blank to represent the unspecified default. For CMYK color specifications, mintty interprets the colorspace ID parameter as specifying the maximum value which the channel values are given out of (e.g. 100 or 255).<ref name="mintty"/> * In addition to the '2' value after 48 to specify a Red-Green-Blue format (and the '5' above for a 0-255 indexed color), there are alternatives of '0' for implementation-defined and '1' for transparent - neither of which have any further parameters; '3' specifies colors using a Cyan-Magenta-Yellow scheme, and '4' for a Cyan-Magenta-Yellow-Black one, the latter using the position marked as "unused" for the Black component.<ref name="T.416"/> ESC[38:2:{{angbr|Color-Space-ID}}:{{angbr|r}}:{{angbr|g}}:{{angbr|b}}:{{angbr|unused}}:{{angbr|[[Color difference|CS tolerance]]}}:{{angbr|Color-Space}}m Select RGB foreground color ESC[48:2:{{angbr|Color-Space-ID}}:{{angbr|r}}:{{angbr|g}}:{{angbr|b}}:{{angbr|unused}}:{{angbr|CS tolerance}}:{{angbr|Color-Space}}m Select RGB background color where {{code|Color-Space}} indicates the Color-Space associated with the given tolerance: {{code|0}} for CIELUV or {{code|1}} for CIELAB. The ITU-RGB variation is supported by xterm, with the colorspace ID and tolerance parameters ignored. The simpler scheme using semicolons is initially found in Konsole.<ref name="xtc"/>{{rp|at=Can I set a color by its number?}} ==== Unix environment variables relating to color support ==== Rather than using the color support in termcap and terminfo introduced in SVr3.2 (1987),<ref>{{cite manual |url=https://invisible-island.net/ncurses/man/curs_color.3x.html#h2-HISTORY |section=History |title=curs_color(3X) - manipulate terminal colors with curses }}</ref> the S-Lang library (version 0.99-32, June 1996) used a separate environment variable {{code|$COLORTERM}} to indicate whether a terminal emulator could use colors at all, and later added values to indicate if it supported 24-bit color.<ref>{{cite web |title=Midnight Commander: lib/tty/color-slang.c|website=Fossies |url=https://fossies.org/linux/mc/lib/tty/color-slang.c}}</ref><ref name=ncurses-on-slang>{{cite web |first=Thomas E. | last=Dickey |title=NCURSES β comments on S-Lang |url=https://invisible-island.net/ncurses/ncurses-slang.html |year=2017 |website=invisible-island.net}}</ref> This system, although poorly documented, became widespread enough for Fedora and RHEL to consider using it as a simpler and more universal detection mechanism compared to querying the now-updated libraries.<ref>{{cite web |title=Features/256 Color Terminals - Fedora Project Wiki |url=https://fedoraproject.org/wiki/Features/256_Color_Terminals#Scope |website=Fedora Project |archive-url=https://web.archive.org/web/20121004184942/https://fedoraproject.org/wiki/Features/256_Color_Terminals#Scope|archive-date=4 October 2012|url-status=live}}</ref> Some terminal emulators (urxvt, konsole) set {{code|$COLORFGBG}} to report the color scheme of the terminal (mainly light vs. dark background). This behavior originated in S-Lang<ref name=ncurses-on-slang/> and is used by vim. Gnome-terminal refuses to add this behavior, as the syntax for the value is not agreed upon, the value cannot be changed upon a runtime change of the palette, and more "proper" xterm OSC 4/10/11 sequences already exist.<ref>{{cite web |title=Bug 733423 β Please set COLORFGBG environment variable for automatic color detection |url=https://bugzilla.gnome.org/show_bug.cgi?id=733423 |website=bugzilla.gnome.org}}</ref>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
ANSI escape code
(section)
Add topic