Every ANSI escape sequence
All 141 ANSI / VT escape sequences this site documents, grouped by wire-protocol family — SGR colour and text attributes, CSI cursor and erase, DEC private modes, OSC terminal control, ESC bare two-byte sequences, DCS device control strings, and C0 single-byte controls. Filter by slug, title, byte form, or spec to jump straight to the page you need.
All sequences, grouped by family
No sequences match. Try a different keyword, byte form, or family name.
SGR (color & attributes)
- SGR 0 — Reset / Normal
\x1b[0mClear all text attributes and colors back to the terminal default.
- SGR 1 — Bold / Increased intensity
\x1b[1mRender following text in bold (or bright on some terminals).
- SGR 2 — Dim / Faint
\x1b[2mRender following text at reduced intensity (faint).
- SGR 5 — Blink (slow)
\x1b[5mBlink the following text (≤ 150 blinks/minute).
- SGR 8 — Conceal / Hidden
\x1b[8mRender following text invisibly (cursor still advances).
- SGR 9 — Strikethrough
\x1b[9mRender following text with a horizontal line through it.
- SGR 39 — Default foreground color
\x1b[39mReset only the foreground color (leaves attributes + bg intact).
- SGR 49 — Default background color
\x1b[49mReset only the background color (leaves attributes + fg intact).
- SGR 48;5;n — 256-color background
\x1b[48;5;NmPick a background color from the 256-color xterm palette.
- SGR 48;2;R;G;B — 24-bit truecolor background
\x1b[48;2;R;G;BmPick any of 16,777,216 background RGB colors directly.
- SGR 3 — Italic
\x1b[3mRender following text in italic; not universally supported.
- SGR 4 — Underline
\x1b[4mRender following text with an underline.
- SGR 7 — Reverse video
\x1b[7mSwap foreground and background colors.
- SGR 30–37 — Foreground color (8 basic)
\x1b[31m (red, similarly 30–37)Set foreground to one of black/red/green/yellow/blue/magenta/cyan/white.
- SGR 40–47 — Background color (8 basic)
\x1b[41m (red bg, 40–47)Set background to one of black/red/green/yellow/blue/magenta/cyan/white.
- SGR 90–97 — Bright foreground color
\x1b[91m (bright red, 90–97)Bright variants of the 8 basic foreground colors (aixterm/xterm extension).
- SGR 100–107 — Bright background color
\x1b[101m (bright red bg, 100–107)Bright variants of the 8 basic background colors.
- SGR 38;5;n — 256-color foreground
\x1b[38;5;NmPick a foreground color from the 256-color xterm palette.
- SGR 38;2;R;G;B — 24-bit truecolor foreground
\x1b[38;2;R;G;BmPick any of 16,777,216 foreground RGB colors directly.
- SGR 21 — Doubly underlined
\x1b[21mRender text with a double underline — distinct from single underline (SGR 4).
- SGR 53 — Overlined
\x1b[53mRender text with a line drawn ABOVE the glyphs — mirror of underline. Disable with SGR 55.
- SGR 26 — Proportional spacing (ECMA-48; ignored by every common terminal)
\x1b[26mDefined by ECMA-48 as 'proportional spacing on' — but no common terminal emulator implements it. Document the gotcha.
- SGR colon sub-parameters — ITU-T T.416 alternative (38:2:: / 48:2:: / 38:5:)
\x1b[38:2::255:128:64m (T.416) \x1b[38;2;255;128;64m (xterm-legacy)Use `:` (0x3a) instead of `;` (0x3b) between extended-color sub-parameters — the spec-blessed form that disambiguates compound SGR codes from independent ones.
- SGR 73 / 74 / 75 — Superscript / Subscript / Neither
\x1b[73m superscript \x1b[74m subscript \x1b[75m neitherMintty's superscript / subscript SGR pair, now shipped by Kitty 0.32+, WezTerm, foot, and iTerm2. The first SGR attribute that lets terminal output typeset math, footnotes, and chemical formulae without trick characters.
CSI (cursor & erase)
- CUU / CUD / CUF / CUB — Move cursor
\x1b[NA (up; B down, C right, D left)Move the cursor up / down / right / left by N cells.
- CNL / CPL — Cursor next / previous line
\x1b[NE (down N lines, col 1) \x1b[NF (up)Move the cursor to column 1 of the line N below (CNL) or above (CPL).
- CHA — Cursor horizontal absolute (column)
\x1b[NGMove the cursor to column N of the current row (1-indexed).
- CUP — Set cursor position
\x1b[row;colHMove the cursor to absolute row/column (1-indexed).
- ED — Erase in display (\x1b[2J clear screen)
\x1b[NJErase part or all of the screen.
- EL — Erase in line (\x1b[K)
\x1b[NKErase part or all of the current line.
- SU / SD — Scroll up / down
\x1b[NS (scroll up) \x1b[NT (scroll down)Scroll the screen contents up (SU) or down (SD) by N lines without moving the cursor.
- DECSCUSR — Cursor shape
\x1b[N\x20q (N = 0..6)Change the cursor shape: block, underline, or bar (with optional blink).
- DECSTR — Soft terminal reset
\x1b[!pReset DEC private modes and SGR to defaults WITHOUT clearing the screen or scrollback.
- CBT — Cursor Backward Tabulation (CSI Z)
\x1b[NZMove the cursor back N tab stops — the reverse of pressing Tab.
- TBC — Tab Clear (CSI g)
\x1b[g (clear current) \x1b[3g (clear all)Clear one or all tab stops, changing where HT and CBT land.
- DECSTBM — Set Top/Bottom Margins (CSI r)
\x1b[T;BrDefine the vertical scrolling region — rows outside it stay pinned, rows inside scroll.
- SCOSC / SCORC — Save / Restore cursor (CSI s / u)
\x1b[s (save) \x1b[u (restore)CSI-style save (s) and restore (u) of cursor position — distinct from ESC 7 / ESC 8 (DECSC / DECRC).
- CHT — Cursor Forward Tabulation (CSI I)
\x1b[NIAdvance the cursor N tab stops — the parameterized form of pressing Tab.
- DA — Device Attributes (CSI c / CSI > c)
\x1b[c (primary DA) \x1b[>c (secondary DA)Ask the terminal what kind of VT it is — primary (CSI c) returns features, secondary (CSI > c) returns model + firmware.
- DSR — Device Status Report (CSI 5n / CSI 6n)
\x1b[5n (status request) \x1b[6n (cursor pos request)Ask for terminal status (5n) or the current cursor position (6n) — the reverse channel TUIs use to size the terminal.
- DECRQM — Request Mode Status (CSI ? Ps $ p)
\x1b[?Ps$pAsk the terminal whether a specific DEC private mode is enabled — used for feature detection at runtime.
- ICH — Insert Character (CSI Pn @)
\x1b[Pn@Shift the rest of the current line right by N cells and blank-fill the gap — the primitive vim's insert mode is built on.
- DCH — Delete Character (CSI Pn P)
\x1b[PnPDelete N cells at the cursor and shift the rest of the line left to fill the gap — the inverse of ICH.
- IL — Insert Line (CSI Pn L)
\x1b[PnLOpen N blank lines at the cursor row and push subsequent lines down within the scrolling region — vim's 'O' command primitive.
- DL — Delete Line (CSI Pn M)
\x1b[PnMRemove N lines starting at the cursor row and pull subsequent lines up within the scrolling region — vim's 'dd' command primitive.
- ECH — Erase Character (CSI Pn X)
\x1b[PnXErase N cells in place at the cursor — same shape as DCH but the rest of the line does NOT shift left.
- REP — Repeat Preceding Character (CSI Pn b)
\x1b[PnbRepeat the most-recently-emitted printing character N times — a bandwidth-saver for runs of identical glyphs.
- VPA — Vertical line position absolute (CSI d)
\x1b[<row>dMove the cursor to an absolute row, keeping the current column.
- HVP — Horizontal and vertical position (CSI f, alias of CUP)
\x1b[<row>;<col>fMove the cursor to absolute (row, col) — semantically identical to CUP but uses final byte `f` instead of `H`.
- XTWINOPS — Window manipulation (CSI Ps ; Ps ; Ps t)
\x1b[<Ps>t or \x1b[<Ps>;<Pa>;<Pb>txterm's window-manipulation family — resize, minimise, raise/lower, query size, push/pop title.
- DECSED / DECSEL — Selective erase display / line (CSI ? Ps J / CSI ? Ps K)
\x1b[?<Ps>J (DECSED) \x1b[?<Ps>K (DECSEL)Erase only the unprotected cells in the display (DECSED) or current line (DECSEL) — the private-mode siblings of ED / EL.
- SL / SR — Scroll left / right (CSI Ps SP @ / CSI Ps SP A)
\x1b[<Ps> @ (SL) \x1b[<Ps> A (SR)Scroll the screen content left (SL) or right (SR) by Ps columns — the horizontal counterpart of CSI S / CSI T.
- DECSCA — Select character protection attribute (CSI Ps " q)
\x1b[<Ps>"qMark subsequently-written cells as DECSED/DECSEL-protected (Ps=1) or unprotected (Ps=0/2).
- DECSLRM — Set left and right margins (CSI Pl ; Pr s)
\x1b[<Pl>;<Pr>sConstrain horizontal cursor movement + scrolling to columns Pl…Pr — the horizontal counterpart of DECSTBM.
- XTPUSHCOLORS / XTPOPCOLORS / XTREPORTCOLORS — Palette stack (CSI # P / # Q / # R)
\x1b[#P (push) \x1b[#Q (pop) \x1b[#R (report)Save / restore / inspect xterm's ANSI palette via a process-local stack — useful for TUIs that mutate the palette temporarily.
- DECDC / DECIC — Delete / insert column (CSI Pn ' ~ / CSI Pn ' })
\x1b[<Pn>'~ (DECDC) \x1b[<Pn>'} (DECIC)Delete (DECDC) or insert (DECIC) Pn columns at the cursor — the column-oriented counterparts of DL (CSI Pn M) and IL (CSI Pn L).
- XTMODKEYS — Modify keyboard reporting (CSI > Pp ; Pv m)
\x1b[><Pp>;<Pv>mSwitch xterm's modifyKeyboard / modifyCursorKeys / modifyFunctionKeys / modifyOtherKeys resources at runtime — the foundation for Ctrl+letter, Alt+letter disambiguation.
- XTSMTITLE / XTRMTITLE — Set / reset title display modes (CSI > Ps ; … t / T)
\x1b[><Ps>;<Ps>…t (set) \x1b[><Ps>;<Ps>…T (reset)Switch how xterm interprets / returns window-title and icon-name strings — hex vs UTF-8 encoding, truncation, set-vs-query behaviour.
- DECSWBV / DECSMBV — Set warning / margin bell volume (CSI Ps SP t / CSI Ps SP u)
\x1b[<Ps> t (DECSWBV) \x1b[<Ps> u (DECSMBV)Adjust the audio volume of the C0 BEL (DECSWBV) and the right-margin warning bell (DECSMBV) — almost universally ignored by modern emulators.
- SGR / urxvt mouse encoding — Mouse-report wire formats (CSI M / CSI < / CSI)
\x1b[M<Cb><Cx><Cy> (legacy) \x1b[<<Cb>;<Cx>;<Cy>M|m (SGR ?1006) \x1b[<Cb>;<Cx>;<Cy>M (urxvt ?1015)The three on-wire formats a terminal uses to report mouse events: legacy CSI M Cb Cx Cy, modern SGR ?1006, and urxvt ?1015 — what's actually in the input stream after DECSET ?100x enables tracking.
- XTVERSION — Report terminal name and version (CSI > Pp q)
\x1b[>0q (query) reply: \x1bP>|<name> <version>\x1b\\Ask the terminal for a human-readable name + version string — the modern alternative to DECDA for feature detection in tools like Helix, Zellij, Neovim.
- CSI ? Ps n — Private DSR (extended status queries)
\x1b[?<Ps>nDEC private Device Status Reports — extended cursor position (?6 DECXCPR with page), printer / UDK / locator / macro-space / memory-checksum status.
- HPA / HPR / VPR — Position absolute & relative (CSI ` / CSI a / CSI e)
\x1b[<col>` (HPA) \x1b[<n>a (HPR) \x1b[<n>e (VPR)ECMA-48's row/col-preserving cursor moves — HPA (absolute column), HPR (relative column), VPR (relative row) — completing the trio anchored by VPA.
- XTSMGRAPHICS — Sixel / ReGIS / color-register capacity query + set (CSI ? Pi ; Pa ; Pv S)
\x1b[?<Pi>;<Pa>;<Pv>SRead / set the terminal's graphics limits — number of sixel color registers, sixel graphics area, ReGIS area. The standard knob for image-aware TUIs to size their bitmaps.
- DECSASD / DECSSDT — Status display routing & type (CSI Ps $ } / CSI Ps $ ~)
\x1b[<Ps>$} (DECSASD) \x1b[<Ps>$~ (DECSSDT)Pick which display surface (main vs status line) receives subsequent output (DECSASD), and what the status line is for (DECSSDT) — DEC VT320's split-screen status row.
- XTQMODKEYS — Query modifyKeys current value (CSI ? Pp m)
\x1b[?<Pp>mAsk xterm what the current modifyKeyboard / modifyCursorKeys / modifyFunctionKeys / modifyOtherKeys value is — the companion query for XTMODKEYS.
- XTPUSHSGR / XTPOPSGR / XTREPORTSGR — SGR stack (CSI Ps + p / + q / + r)
\x1b[#{ (XTPUSHSGR, alt: CSI Pm + p) \x1b[#} (XTPOPSGR, alt: CSI + q) \x1b[+r (XTREPORTSGR)Save / restore / inspect the current SGR attributes via a stack — the SGR analogue of XTPUSHCOLORS for the palette.
- DECSCPP — Select columns per page (CSI Pn $ |)
\x1b[80$| (80 cols) \x1b[132$| (132 cols)Resize the active page to 80 or 132 columns — the data-side request that DECCOLM expresses as a private mode toggle.
- Secondary DA reply decoder — `CSI > Pp ; Pv ; Pc c` model / firmware / cart
\x1b[>Pp;Pv;PccDecoder reference for the secondary Device Attributes reply — what each Pp model code means and how kitty / wezterm / alacritty / iTerm2 / Ghostty encode their version in Pv.
- XTSAVE / XTRESTORE — Save / restore DEC private mode (`CSI ? Pm s` / `CSI ? Pm r`)
\x1b[?<Pm>s (save) \x1b[?<Pm>r (restore)Stash one or more DEC private mode states on a stack, then restore them later — the foundation tmux / screen / fzf use to safely toggle mouse / alt-screen / paste modes without trampling user prefs.
- DECSCL — Select conformance level (`CSI Pl ; Pc " p`)
\x1b[<Pl>;<Pc>" pChoose VT100 / VT200 / VT300 / VT400 / VT500 conformance level — controls which subset of escape sequences the terminal honours, plus 7-bit vs 8-bit C1 emission. Implicitly performs a hard reset (RIS) first.
- DECSTR side-effects — exactly which modes `\x1b[!p` resets
\x1b[!pReference enumeration of every DEC mode / attribute that DECSTR (soft reset) restores to its default — what gets cleared, what survives, and where xterm vs kitty vs iTerm2 diverge.
- DECRPM decoder — parsing the DECRQM reply (`CSI ? Ps ; Pm $ y`)
\x1b[?<Ps>;<Pm>$y (private) \x1b[<Ps>;<Pm>$y (ANSI)How to read the `CSI ? Ps ; Pm $ y` (and `CSI Ps ; Pm $ y`) reply that DECRQM returns — the `Pm` value tells you whether the mode is set / reset / always-set / always-reset / unrecognised.
- DEC locator suite — DECELR / DECEFR / DECSLE / DECRQLP (mouse / locator events)
\x1b[<Pn>;<Pu>'z \x1b[<Pm>'{ \x1b[<Pt>;<Pl>;<Pb>;<Pr>'w \x1b[<Ps>'|The original DEC pointing-device protocol (predates xterm SGR mouse modes by a decade). Four sequences enable, filter, select, and query locator events; modern interactive UIs use SGR mouse modes (`?1000` + `?1006`) instead.
- DECREQTPARM / DECREPTPARM — Request and report terminal parameters (`CSI Ps x`)
\x1b[<Ps>xVT100-era legacy probe — ask the terminal for its serial-line parameters (parity, bit-count, baud, clock multiplier, flags). Predates DA / DA2 / XTVERSION; almost never the right tool now, but xterm and most modern emulators still answer with synthetic defaults.
- DECCARA / DECRARA — Change / Reverse attributes in rectangular area (`CSI Pt;Pl;Pb;Pr;Ps;… $ r` / `$ t`)
\x1b[<Pt>;<Pl>;<Pb>;<Pr>;<Ps>;…$r (DECCARA) \x1b[<Pt>;<Pl>;<Pb>;<Pr>;<Ps>;…$t (DECRARA)Set or XOR SGR attributes across a rectangle of cells without rewriting any character data — the rectangular-attribute siblings of the copy/fill/erase ops in `dec-rect-ops`.
- DECPS — Play Sound (`CSI Pv ; Pd ; Pn1 [; …] , ~`)
\x1b[<Pv>;<Pd>;<Pn1>[;<Pn2>…],~DEC VT520 musical-tone playback — `Pv` volume, `Pd` duration, then one or more `Pn` MIDI-style note numbers. Niche but implemented by xterm, WezTerm, Ghostty, mlterm; the only ANSI way to make the terminal beep at a specific pitch.
- DECTABSR — Tab Stop Report (`CSI 2 $ w`)
\x1b[2$wAsk the terminal to dump its current horizontal tab stops as a DCS report. Closes the round-trip story: set via HTS (`esc-hts`), clear via TBC (`csi-tbc`), query the current set via DECTABSR.
- DECRQCRA / DECCKSR — Request Checksum of Rectangular Area (`CSI Pi;Pg;Pt;Pl;Pb;Pr*y`)
\x1b[Pi;Pg;Pt;Pl;Pb;Pr*y reply \x1bP<Pi>!~<hex4>\x1b\\Ask the terminal to compute a 16-bit checksum over a rectangle of cells (`CSI Pi;Pg;Pt;Pl;Pb;Pr*y`); reply arrives as DCS DECCKSR (`\x1bP<Pi>!~<hex4>\x1b\\`). The xterm vttest / ConPTY conformance pin.
- DECLL — Load LEDs (`CSI Ps q`, no SP intermediate)
\x1b[Ps qTurn the keyboard's front-panel L1–L4 LEDs on / off (`CSI Ps q`). Surviving in Linux-console terminfo as `KEYBOARD_LED 1/2/3/4` — modern emulators silent no-op except xterm + Linux console.
- DECCRA / DECFRA / DECERA / DECSERA — Copy / Fill / Erase / Selective-erase rectangular area
\x1b[<Pts>;<Pls>;<Pbs>;<Prs>;<Pps>;<Ptd>;<Pld>;<Ppd>$v DECCRA\n\x1b[<Pch>;<Pt>;<Pl>;<Pb>;<Pr>$x DECFRA\n\x1b[<Pt>;<Pl>;<Pb>;<Pr>$z DECERA\n\x1b[<Pt>;<Pl>;<Pb>;<Pr>${ DECSERAThe four content-side rectangle ops missing from the DEC rect family — copy a block, fill it with a glyph, erase to space, or erase only non-protected cells. Pairs with DECCARA / DECRARA (attribute-side) and DECSACE (block-vs-stream toggle).
- DECSACE — Select Attribute Change Extent (`CSI Ps * x`)
\x1b[<Ps>*xToggle whether DECCARA / DECRARA treat their rectangle as a literal cell block (default) or as a stream from start-position to end-position. The content-side rect ops (DECCRA / DECFRA / DECERA / DECSERA) are unaffected.
- CSI Ps i — Media Copy (MC) — printer-on / printer-off / print line
\x1b[0i / \x1b[4i / \x1b[5i / \x1b[?4i / \x1b[?5iECMA-48 §8.3.82 control that historically routed terminal output to an attached printer. Survives today as the 'print screen' hook on xterm/mlterm, the IBM-3270 emulator pass-through, and as private-mode `CSI ? 4 / 5 i` auto-print toggles consumed by `expect`-style automation.
- DECRQDE / DECRPDE — Request / Report Displayed Extent (`CSI " v` / `" w`)
\x1b["v DECRQDE (request)\n\x1b[<Ph>;<Pw>;<Pml>;<Pmt>;<Pmp>"w DECRPDE (reply)VT420+ pagination query — ask the terminal how many rows / columns are currently displayed and where the scroll window sits inside the page memory. Reply tells the host the visible viewport without relying on `tput lines / cols`.
DEC private modes
- DECSC / DECRC — Save and restore cursor
\x1b7 (save) \x1b8 (restore)Push and pop the cursor state (position + attributes).
- DECSET 1049 — Alternate screen buffer
\x1b[?1049h (enter) \x1b[?1049l (leave)Switch to a separate screen buffer (like vim/less do on launch).
- DECTCEM ?25 — Show/hide cursor
\x1b[?25h (show) \x1b[?25l (hide)Show or hide the text cursor.
- DECSET ?2004 — Bracketed paste mode
\x1b[?2004h (enable) \x1b[?2004l (disable)Wrap pasted text in distinct escape markers so apps can tell paste from typing.
- DECSET ?1000 / ?1006 — Mouse tracking
\x1b[?1000h (click only) \x1b[?1002h (cell drag) \x1b[?1003h (any motion) \x1b[?1006h (SGR encoding)Receive mouse click / drag / scroll events as escape sequences.
- DECAWM ?7 — Auto-wrap mode
\x1b[?7h (enable wrap) \x1b[?7l (disable)Toggle whether the cursor wraps to the next line at the right margin (default: on).
- DECSET ?1004 — Focus in/out events
\x1b[?1004h (enable) \x1b[?1004l (disable)Make the terminal report when its window gains or loses keyboard focus.
- DECSET ?2026 — Synchronized update mode
\x1b[?2026h (begin frame) \x1b[?2026l (end frame)Buffer screen updates until you signal end-of-frame — eliminates flicker on full repaints.
- DECSET ?12 — Cursor blink
\x1b[?12h (start blinking) \x1b[?12l (stop blinking)Enable or disable the blinking attribute of the cursor — independent of cursor shape.
- DECOM ?6 — Origin mode (clip cursor addressing to scroll region)
\x1b[?6h (origin = region) \x1b[?6l (origin = screen)Make the cursor's row/column origin (1,1) be the top-left of the DECSTBM region instead of the screen.
- DECSET ?1047 — Alt screen without cursor save
\x1b[?1047h (enter alt) \x1b[?1047l (leave alt)Switch to / from the alt screen WITHOUT saving the cursor — the bare-bones precursor to ?1049.
- DECSDM — Sixel display mode (CSI ? 80 h / l)
\x1b[?80h (set) \x1b[?80l (reset)Choose the cursor's resting position after a sixel render — at top-left of the image (private-mode set) or below the image (reset, the modern default).
- DECSCNM — Reverse video screen mode (CSI ? 5 h / l)
\x1b[?5h (reverse) \x1b[?5l (normal)Globally swap foreground and background colours for the entire screen — the screen-wide reverse-video toggle, distinct from per-cell SGR 7.
- DECSCLM — Smooth scrolling mode (CSI ? 4 h / l)
\x1b[?4h (smooth) \x1b[?4l (jump)Toggle between smooth (one-line-per-frame animated) and jump (instant) scrolling — a DEC VT100 hardware-era setting that modern emulators almost universally ignore.
- DECARM — Auto-repeat keys mode (CSI ? 8 h / l)
\x1b[?8h (repeat) \x1b[?8l (no repeat)Toggle whether the terminal repeats key bytes while a key is held down — a TUI-relevant knob for games and editors where holding `j` should NOT spam the buffer.
- DECCOLM — 80 / 132 column mode (CSI ? 3 h / l)
\x1b[?3h (132 cols) \x1b[?3l (80 cols)Toggle between 80 and 132 column page width — DEC VT100's flagship 'wide mode' switch, gated by an opt-in resource on every modern emulator.
- DECNCSM — No Clear Screen on column-mode change (`CSI ? 95 h / l`)
\x1b[?95h (set — preserve) \x1b[?95l (reset — clear)Suppress DECCOLM's (and DECSCPP's) implicit screen-clear side-effect. With DECNCSM set, switching between 80- and 132-column modes preserves cell contents instead of wiping them.
OSC (terminal control)
- OSC 0 / 2 — Set window/icon title
\x1b]0;TITLE\x07Change the terminal window's title bar text.
- OSC 8 — Inline hyperlink
\x1b]8;;URI\x07TEXT\x1b]8;;\x07Render clickable hyperlinks in terminal output (gnome-terminal 3.26+, iTerm2, Windows Terminal, kitty, ...).
- OSC 10 / 11 — Set default foreground / background color
\x1b]10;#RRGGBB\x07 (set fg) \x1b]11;#RRGGBB\x07 (set bg)Set the terminal's default foreground (OSC 10) or background (OSC 11) color, or query the current value.
- OSC 52 — System clipboard read/write
\x1b]52;c;BASE64\x07 (set clipboard 'c' to BASE64 decoded bytes)Set (or query) the host system clipboard via the terminal — works over SSH without X11 forwarding.
- OSC 4 — Set palette colour (and query)
\x1b]4;N;#RRGGBB\x07 (set) \x1b]4;N;?\x07 (query)Change one of the 256 palette colours, or query its current value.
- OSC 9 — Toast notification (iTerm2 / Windows Terminal)
\x1b]9;MESSAGE\x07Trigger a native OS desktop notification from the terminal — long-running job done, build finished, etc.
- OSC 7 — Current working directory hint
\x1b]7;file://HOST/PATH\x07Tell the terminal which directory the shell is in — used for tab labels, 'new tab here', and remote-aware split-pane workflows.
- OSC 110 / 111 / 112 — Reset default fg / bg / cursor colour
\x1b]110\x07 (reset fg) \x1b]111\x07 (reset bg) \x1b]112\x07 (reset cursor)Restore the terminal's user-default foreground, background, or cursor colour after OSC 10 / 11 / 12 overrode it.
- OSC 12 — Set cursor colour (and query)
\x1b]12;#RRGGBB\x07 (set) \x1b]12;?\x07 (query)Override the terminal's cursor colour, or query the current value via the OSC reply.
- OSC 17 — Set highlight (selection) background colour
\x1b]17;#RRGGBB\x07 (set) \x1b]17;?\x07 (query)Change the background colour the terminal paints behind selected (highlighted) text.
- OSC 19 — Set highlight (selection) foreground colour
\x1b]19;#RRGGBB\x07 (set) \x1b]19;?\x07 (query)Change the foreground colour the terminal uses for selected (highlighted) text.
- OSC 104 — Reset palette colour (one index or all)
\x1b]104;N\x07 (reset index N) \x1b]104\x07 (reset all)Restore one palette index — or the whole 256-colour palette — to the terminal's user-configured defaults.
- OSC 1 — Set icon name (separate from window title)
\x1b]1;ICON-NAME\x07Set the X11-style icon name independent of the visible window title — historically the label shown when the window is minimised.
- OSC 22 — Set X11 mouse pointer / cursor name
\x1b]22;CURSOR-NAME\x07Override the mouse-pointer glyph the terminal window draws — historically xterm-specific, exposed via standard X cursor names.
- OSC 50 — Set or query font (xterm font selector)
\x1b]50;FONT-SPEC\x07 (set) \x1b]50;?\x07 (query)Switch the terminal's display font at runtime, or query the current font — xterm extension, also implemented by a handful of forks.
- OSC 133 — Semantic prompt marks (FinalTerm A / B / C / D)
\x1b]133;A\x07 (prompt start) \x1b]133;B\x07 (command start) \x1b]133;C\x07 (output start) \x1b]133;D;<exit>\x07 (command end)Tag shell prompt-start / command-start / output-start / command-end so the terminal can jump between prompts, fold output, and decorate exit codes.
- OSC 1337 — iTerm2 inline images & file transfer
\x1b]1337;File=name=<base64>;size=<bytes>;inline=1:<base64-data>\x07Embed images, files, or proprietary iTerm2 state into the terminal stream — the predecessor protocol that Kitty / Sixel later largely supplanted.
- OSC 9 ; 4 — ConEmu progress indicator (Windows Terminal / Ghostty)
\x1b]9;4;<state>;<percent>\x07Push live progress percentages / paused / error states to the taskbar or tab icon — the ConEmu protocol that Windows Terminal 1.18+ standardised.
- OSC 10 / 11 / 12 query — Detect default fg / bg / cursor color (dark vs light)
\x1b]10;?\x07 (fg) \x1b]11;?\x07 (bg) \x1b]12;?\x07 (cursor)Ask the terminal for its current default foreground (10) / background (11) / cursor (12) color — the canonical way to auto-pick a dark or light theme.
- OSC 4 query — Read 256-color palette index (`\x1b]4;<n>;?\x07`)
\x1b]4;<n>;?\x07Ask the terminal what RGB value is currently bound to palette index `n` (0–255) — used by theme inspectors, screenshot tools, and palette-migration scripts.
ESC (bare escape sequences)
- RIS — Reset to Initial State (full terminal reset)
\x1bcHard reset the terminal: clear screen + scrollback, reset every mode and SGR, home the cursor.
- HTS — Horizontal Tab Set (ESC H)
\x1bHSet a tab stop at the current cursor column — partner to TBC.
- C1 controls — 8-bit single-byte equivalents of ESC sequences (0x80–0x9F)
\x9b CSI \x9d OSC \x9c ST \x90 DCS \x85 NEL \x88 HTS \x84 IND \x8d RIThe 8-bit C1 control bytes (0x80..0x9F) — CSI, OSC, ST, DCS, NEL, HTS, IND, RI — and their 7-bit ESC <letter> equivalents.
- DECKPAM / DECKPNM — Keypad application / numeric mode (ESC = / ESC >)
\x1b= (DECKPAM) \x1b> (DECKPNM)Switch the numeric keypad between sending application escape sequences (\eOM / \eOj …) and plain ASCII digits — the foundation of vim / less / readline keypad behaviour.
- DECDHL / DECDWL / DECSWL — Double-height / double-width lines (ESC # 3 / # 4 / # 5 / # 6)
\x1b#3 (DHL top) \x1b#4 (DHL bottom) \x1b#5 (DECSWL) \x1b#6 (DECDWL)Mark the current line as double-height (top or bottom half) or double-width / single-height — DEC's per-line big-banner primitives, used by VT100 splash screens.
- DECALN — Screen alignment pattern (ESC # 8)
\x1b#8Fill the entire screen with capital `E` glyphs — DEC's CRT alignment test, the canonical 'is the page buffer wired up right' smoke test.
- Single Shift / Locking Shift family — SS2 / SS3 / LS2 / LS3 / LS1R / LS2R / LS3R
\x1bN SS2 \x1bO SS3 \x1bn LS2 \x1bo LS3 \x1b~ LS1R \x1b} LS2R \x1b| LS3RISO 2022 character-set switching: invoke G2 / G3 once (SS2 / SS3), or lock GL / GR to a different G-set (LS2 / LS3 / LS1R / LS2R / LS3R). Pairs with `\x1b(` / `\x1b)` / `\x1b*` / `\x1b+` G-set designators.
- APC — Application Program Command (`ESC _ … ESC \\` / `\x9F … \x9C`)
\x1b_<body>\x1b\\ (7-bit) \x9f<body>\x9c (8-bit C1)The string introducer ECMA-48 reserves for application-to-application messages. Modern use: Kitty graphics protocol, VS Code shell integration, Windows Terminal API patches. Sibling to DCS / OSC / PM / SOS.
DCS (device control strings)
- DCS Sixel — Inline raster graphics (ESC P q … ESC \)
\x1bPq <sixel data> \x1b\\Embed pixel images in the terminal stream using the Sixel device-control payload.
- Kitty graphics protocol — Inline pixel images (ESC _ G … ESC \)
\x1b_Ga=T,f=100,m=1;BASE64_CHUNK\x1b\\Modern alternative to Sixel: stream PNG / RGBA bytes to the terminal via the Kitty APC frame, with sane chunking and a placement protocol.
- DECRQSS — Request Selection or Setting (DCS $ q ... ST)
\x1bP$q<P>\x1b\\Ask the terminal to report the current value of any SGR / mode / margin / cursor-shape setting — the catch-all DCS query.
- XTGETTCAP — Request terminfo capability (DCS + q ... ST)
\x1bP+q<HEX-NAME>;<HEX-NAME>...\x1b\\Ask the terminal to report a terminfo capability value by its name — the runtime way to probe true-colour, RGB, OSC 52, etc.
- DECUDK — Define User-Defined Keys (DCS Pc;Pl|Ky/St;... ST)
\x1bPPc;Pl|Ky/St;Ky/St;...\x1b\\Remap the DEC user-defined function keys (F6–F20) at runtime — legacy DEC VT, still decoded by xterm and its forks.
- DECDLD — Dynamically Redefinable Character Set (DCS ... { ... ST)
\x1bPPfn;Pcn;Pe;Pcms;Pw;Pt{Dscs Sxbp1;Sxbp2;...\x1b\\Download a soft glyph bitmap into a slot the terminal can then display alongside the built-in font — pure DEC VT220+ legacy.
- DECRSPS — Restore Presentation State (DCS $ t ... ST)
\x1bP1$t<saved-state>\x1b\\ (cursor) \x1bP2$t<saved-state>\x1b\\ (tab stops)Inverse of DECRQSS — feed back a previously-saved cursor / SGR / margin snapshot to restore the terminal's exact state.
- DECDMAC / DECINVM — Define & invoke macro (DCS Pn ; Pn ; Pn ! z ... ST / CSI Pn * z)
\x1bP<Pid>;<Pdt>;<Penc>!z<MACRO-BODY>\x1b\\ (define) \x1b[<Pid>*z (invoke)Store a byte sequence under a numeric handle (DECDMAC), then replay it on demand (DECINVM) — DEC VT520's terminal-side macro recorder.
- DECSCUSR query via DECRQSS — Read the current cursor shape (`\x1bP$q q\x1b\\`)
\x1bP$q q\x1b\\Round-trip the cursor-shape parameter — query side of DECSCUSR via DECRQSS, terminal replies with the current `Ps SP q` setting.
- DECRQUPSS / DECAUPSS — Request / Assign User-Preferred Supplemental Set
\x1b[&u request \x1bP<Ps>!u<D…D>\x1b\\ assignQuery (`CSI & u`) and assign (`DCS Ps ! u … ST`) the supplemental character set the terminal maps into the GR slot when no Locking Shift is active. Closes the supplemental-set plumbing left after `single-locking-shift`.
- DECRQTSR / DECRSTS — Request / Restore Terminal State Report
\x1b[Ps$u request \x1bP<Ps>$p<body>\x1b\\ restoreSave (`CSI Ps$u` → DCS reply) and restore (`DCS Ps$p…ST`) the whole DEC terminal state — the terminal-wide complement to `dcs-decrsps`' presentation-state-only scope.