TUI swallows iTerm2 proprietary escape sequences, preventing terminal marks for navigation
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
Long Claude Code sessions are difficult to navigate — there's no way to quickly jump between prompts. iTerm2 solves this for normal shell sessions via marks (blue triangles in the gutter that you navigate with Cmd+Shift+Up/Down), but Claude Code's TUI prevents this from working.
I attempted to use a Stop hook to set an iTerm2 mark after each response:
{
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "printf '\\e]1337;SetMark\\a' > /dev/tty"
}
]
}
]
}
}
The hook fires, but the escape sequence \e]1337;SetMark\a is swallowed by the TUI — even writing directly to /dev/tty doesn't reach iTerm2.
We were able to work around the escape sequence issue by using AppleScript to trigger the menu item directly:
{
"command": "osascript -e 'tell application \"System Events\" to tell process \"iTerm2\" to click menu item \"Set Mark\" of menu \"Marks and Annotations\" of menu item \"Marks and Annotations\" of menu \"Edit\" of menu bar 1'"
}
This successfully set marks, but they were ultimately overwritten by the TUI's screen redraws, making them useless for navigation.
This is related to #11060, which requested conversation navigation features and was auto-closed.
Proposed Solution
Option A — Pass through iTerm2 escape sequences: If the TUI forwarded proprietary escape sequences (like OSC 1337) to the host terminal, users could set marks via hooks and navigate with native iTerm2 shortcuts. This would work for any terminal that supports similar features (Kitty, WezTerm, etc.).
Option B — Emit marks natively: Claude Code could emit iTerm2/terminal mark escape sequences at each prompt boundary as part of its rendering, so terminal-level navigation just works out of the box.
Option C — Built-in prompt navigation: Add a keybinding (e.g., Ctrl+Up/Down) within the TUI to jump between user prompts.
Priority
High - Significant impact on productivity
Feature Category
Interactive mode (TUI)
Additional Context
iTerm2 mark escape sequence: ESC ] 1337 ; SetMark ST (docs)
Related: #11060 (requested jump-to-prompt navigation, auto-closed)
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗