iTerm2 — ANSI escape code support
iTerm2 is the de facto modern terminal emulator for macOS, written by George Nachman and continuously developed since 2006. It tracks every xterm-ctlseqs addition and ships several proprietary extensions of its own — inline images via OSC 1337, tmux integration mode, native truecolor without a $COLORTERM check, and one of the broadest implementations of the kitty styled-underline grammar.
It also implements the most aggressive optimizations: synchronized output (DECSET ?2026), Unicode 15 width tables, and a metal renderer. For ANSI-escape compatibility purposes, iTerm2 is a strict superset of xterm.
Last updated
Feature support
How this terminal scores against the 15 features tracked in the site-wide support matrix. Click any feature name to see the full row across every terminal.
- 8 basic colors (30–37 / 40–47)SGR 30–37 foreground, 40–47 background.yes
- Bright (aixterm) colors (90–97 / 100–107)aixterm SGR extension.yes
- 256-color palette (38;5;n / 48;5;n)xterm 256-color extension.yes
- 24-bit truecolor (38;2;r;g;b)16.7M direct RGB. Set $COLORTERM=truecolor.yes
- Italic (SGR 3)Italic text attribute.yes
- Styled underlines (4:1–4:5)Curly/dotted/dashed underline styles.yes
- Strikethrough (SGR 9)Horizontal line through text.yes
- OSC 8 hyperlinksInline clickable URIs.yes
- Alt screen (?1049h)Full-screen app buffer.yes
- Mouse tracking (SGR ?1006)Mouse click/drag events.yes
- Bracketed paste (?2004)Pasted text wrapped in ESC[200~/ESC[201~.yes
- Focus events (?1004)ESC[I on focus in, ESC[O on focus out.yes
- Sixel graphicsDEC sixel inline raster images.yes
- Kitty graphics protocolPNG/RGB inline images, animations.no
- Synchronized output (?2026)Atomic frame updates to avoid tearing.yes
Sequences that work here
Canonical reference pages for the escape sequences this terminal handles cleanly. Each links to a full page with byte forms, citations, and per-language examples.
- 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 1 — Bold / Increased intensity
\x1b[1mRender following text in bold (or bright on some terminals).
- DECSET 1049 — Alternate screen buffer
\x1b[?1049h (enter) \x1b[?1049l (leave)Switch to a separate screen buffer (like vim/less do on launch).
- 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 0 / 2 — Set window/icon title
\x1b]0;TITLE\x07Change the terminal window's title bar text.
Quirks & version notes
Per-terminal caveats you'll want to know before relying on a sequence in production.
- Native truecolor without $COLORTERM
- iTerm2 parses SGR 38;2;r;g;b regardless of $COLORTERM, $TERM, or terminfo entry. Apps that gate truecolor on `process.env.COLORTERM === "truecolor"` will downgrade to 256-color anyway — set the variable explicitly in your shell profile (or use iTerm2's built-in option Preferences → Profiles → Terminal → Report Terminal Type: xterm-direct).
- OSC 1337 — proprietary image/file protocol
- iTerm2's `imgcat` and inline-image features use `OSC 1337 ; File=name=...;inline=1 : <base64 png> BEL`. This sits outside xterm-ctlseqs entirely. Detect iTerm2 via the LC_TERMINAL=iTerm.app environment variable iTerm2 sets on every new shell, or via DA1 secondary response, before emitting OSC 1337.
- Synchronized output is on by default
- DECSET ?2026h begins an atomic frame; ?2026l flushes. iTerm2 has supported this since build 3.4.18 (2022) and turns it on by default. Apps like tmux, kitty, and modern TUI frameworks (Ratatui, Textual, Bubbletea) emit it automatically — no opt-in needed on iTerm2 itself.
- Kitty graphics protocol: deliberately not supported
- iTerm2 has rejected the kitty graphics protocol (`_G` APC sequences) in favour of the older OSC 1337. The two protocols are not interchangeable. Cross-terminal image libraries (term-image, viu) feature-detect via DA1 + terminal-name and dispatch to the right protocol — neither one is a portable fallback for the other.