Terminal Features: How Escape Sequences Work

ankitg121 pts0 comments

Terminal Features: How Escape Sequences Work | Terminfo.dev

Skip to content<br>Appearance

MenuReturn to top

Terminal Features ​<br>270 features across 13 categories — tested across major terminal emulators<br>Most terminal features — color changes, cursor moves, mode switches — are controlled by escape sequences , byte patterns your terminal interprets instead of displaying. Some features (text wrapping, character width, scrollback behavior) are behavioral properties that terminals implement without explicit control sequences. This page catalogs them all, with support data from major terminals. See the glossary for acronyms.

How Escape Sequences Work ​<br>Most terminal features are controlled by escape sequences — special byte patterns that tell the terminal to do something other than display text. When a program writes \x1b[1m, it's not printing four characters; it's telling the terminal "make the following text bold." The terminal intercepts the pattern, changes its internal state, and displays subsequent characters accordingly. Some features below are behavioral properties — like text wrapping and character width — that terminals implement without explicit control sequences.<br>The CSI (Control Sequence Introducer) ESC [ (hex 1b 5b) is the prefix for most sequences. What follows the CSI determines the operation: SGR (m suffix) for text styling, CUP (H suffix) for cursor positioning, DECSET (?...h) for enabling modes. Parameters are semicolon-separated numbers. Sub-parameters (colon-separated, from ECMA-48 but rarely used until Kitty adopted them) enable richer expressions like 4:3 for curly underline.<br>ECMA-48 defines a family of control-sequence formats (CSI, OSC, DCS, and others); terminals differ mainly in which parameters and functions they implement. The complexity lives in which parameter values each terminal recognizes — and that's exactly what terminfo.dev measures.<br>Escape Sequences in Action ​<br>SequenceRendersFeatureESC[1mHelloESC[0mHello Bold (SGR 1)ESC[3mHelloESC[0mHelloItalic (SGR 3)ESC[4mHelloESC[0mHelloUnderline (SGR 4)ESC[38;2;255;100;0mHelloESC[0mHello TruecolorESC[5;10Hcursor jumps to row 5, col 10Cursor PositionESC[?1049hscreen clearsAlternate ScreenESC[6nterminal replies ESC[24;80RCursor ReportESC[>1ukeyboard sends unambiguous keysKitty Keyboard<br>TIP<br>In practice, control sequences use the 7-bit form starting with ESC (byte 0x1B). ECMA-48 also defines 8-bit C1 forms (e.g., CSI as 0x9B), but they're rarely used. Your terminal processes thousands of these per second — a single screen redraw in vim or htop can involve hundreds of cursor moves, color changes, and text writes, all encoded as these tiny byte patterns.

Categories ​<br>🎨SGR (Text Styling)32 features<br>35 ways to style text, and terminals disagree on at least 5 of them<br>Top:iTerm2 (100%), Ghostty (100%), VS Code (100%)<br>▮Cursor22 features<br>15 sequences for moving a blinking rectangle around a grid<br>Top:iTerm2 (91%), Ghostty (91%), Kitty (86%)<br>📝Text20 features<br>The fundamentals: output, wrapping, wide characters, tabs<br>Top:iTerm2 (85%), Ghostty (85%), VS Code (75%)<br>🧹Erase11 features<br>Surgical removal of characters, lines, and screens<br>Top:iTerm2 (100%), Ghostty (100%), VS Code (100%)<br>✂️Editing17 features<br>Insert and delete — the sequences that make vim possible<br>Top:iTerm2 (94%), Ghostty (94%), VS Code (94%)<br>⚙️Modes30 features<br>The terminal's settings panel, controllable via escape sequences<br>Top:iTerm2 (93%), Ghostty (93%), VS Code (90%)<br>📜Scrollback10 features<br>The least standardized area of terminal emulation<br>Top:iTerm2 (90%), Ghostty (90%), VS Code (90%)<br>🔄Reset5 features<br>Returning the terminal to a known state<br>Top:iTerm2 (100%), Ghostty (100%), VS Code (100%)<br>🚀Extensions79 features<br>Where the standard ends and innovation begins<br>Top:iTerm2 (89%), Ghostty (84%), VS Code (82%)<br>🔤Character Sets4 features<br>Box-drawing characters from the VT100 era<br>Top:iTerm2 (100%), Ghostty (100%), VS Code (100%)<br>📡Device Status28 features<br>How applications ask "who are you?" and "where am I?"<br>Top:iTerm2 (54%), Ghostty (43%), VS Code (39%)<br>⌨️Input Protocols8 features<br>Enhanced keyboard and mouse reporting beyond VT100<br>Top:iTerm2 (88%), Ghostty (88%), VS Code (88%)<br>🌐Unicode4 features<br>UTF-8 is table stakes; width is where terminals disagree<br>Top:iTerm2 (100%), Ghostty (100%)

SGR (Text Styling) — The Most Common Escape Codes ​<br>SGR (Select Graphic Rendition) sequences control every visual aspect of text: bold , italic , underline (5 styles including curly, dotted, and dashed), 256-color and truecolor (24-bit RGB) foregrounds and backgrounds, strikethrough , overline , and inverse video . SGR uses the m suffix: ESC[1m for bold, ESC[38;2;255;0;0m for red truecolor foreground.<br>Support ranges from universal (bold, basic 8 colors) to inconsistent (curly underline with independent underline color, overline). The curly underline (SGR 4:3) is especially interesting — it uses ECMA-48's colon sub-parameter syntax that was largely ignored for decades until Kitty adopted it.<br>View SGR...

features terminal sequences iterm2 ghostty code

Related Articles