Add OSC 133 semantic prompt sequences for terminal integration
Summary
Claude Code should emit OSC 133 Semantic Prompt escape sequences to enable modern terminal features like click-to-move cursor, jump-to-prompt, and select command output.
Motivation
Terminals like Ghostty (1.3+), iTerm2, WezTerm, and others support OSC 133 to understand prompt boundaries. When a CLI application emits these sequences, users get:
- Click-to-move cursor — click within the prompt input area to reposition the cursor (Ghostty 1.3+ via
cl=lineextension, PR #10455) - Jump-to-prompt — keyboard shortcut to jump between prompts in scrollback
- Select command output — easily select just the output of a command
Claude Code already uses several terminal escape sequences (bracketed paste mode 2004, synchronized updates mode 2026, focus events mode 1004), so this would follow existing patterns.
Proposed Implementation
Emit the following sequences at the appropriate points in the readline/prompt lifecycle:
| Sequence | When | Purpose |
|---|---|---|
| \x1b]133;A;cl=line\x07 | Before rendering the prompt | Marks prompt start, opts into click-to-move |
| \x1b]133;B\x07 | After prompt, before user input | Marks where user input begins |
| \x1b]133;C\x07 | When user submits input (Enter) | Marks start of command execution |
| \x1b]133;D\x07 | After output completes | Marks end of command output |
The cl=line parameter in the A sequence tells the terminal to translate mouse clicks into left/right arrow key sequences for cursor repositioning within a single line.
Environment
- Ghostty 1.3+ supports
click_eventsandcl=lineextensions to OSC 133 - Fish 4+ and Nushell 0.111+ already emit these sequences natively
- Standard zsh/bash shell integration in terminals like Ghostty also emits them
References
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗