{
  "id": "terminal-osc/51",
  "family": "terminal-osc",
  "slug": "51",
  "title": "OSC 51 — Shell integration (iTerm2)",
  "summary": "OSC 51 is iTerm2's shell integration protocol for marking prompts and commands (similar to OSC 133 but iTerm2-specific).",
  "kind": "control-sequence",
  "aliases": [
    "OSC 51",
    "OSC 51 — Shell integration (iTerm2)"
  ],
  "status": "de-facto",
  "verification": "verified",
  "tier": "B",
  "source_url": "https://invisible-island.net/xterm/ctlseqs/ctlseqs.html",
  "source_version": "xterm ctlseqs, patch #410, 2026/04/19",
  "retrieved_date": "2026-05-29",
  "see_also": [],
  "ext_type": "terminal-escape@1",
  "ext": {
    "csi_or_osc": "OSC",
    "command_number": 51,
    "frame": {
      "introducer_7bit": "\u001b]",
      "introducer_7bit_readable": "ESC ] (0x1B 0x5D)",
      "introducer_8bit": "",
      "introducer_8bit_readable": "0x9D (single-byte OSC, 8-bit C1)",
      "note": "OSC 51 ; ... ST."
    },
    "terminator": "ST|BEL",
    "terminator_detail": {
      "canonical_ST_7bit": "\u001b\\",
      "alt_BEL": "\u0007",
      "note": "ECMA-48 mandates ST; BEL is widely accepted."
    },
    "params": [
      {
        "id": "mark",
        "anchor": "#mark",
        "name": "Mark prompt",
        "meaning": "OSC 51 ; A ST marks the start of a prompt (iTerm2 variant).",
        "required": true,
        "byte_sequence_ST": "\u001b]51;A\u001b\\",
        "byte_sequence_ST_readable": "ESC ] 5 1 ; A ST",
        "subparams": []
      }
    ],
    "gotchas": [
      "OSC 51 is iTerm2-specific; OSC 133 is the cross-terminal standard.",
      "Prefer OSC 133 for cross-terminal compatibility."
    ],
    "v1_smoke_test": {
      "asserts": "OSC 51 renders as a byte-exact ST-terminated OSC sequence.",
      "behavioral_conformance": "deferred to v2."
    }
  },
  "updated": "2026-05-29"
}
