[Bug] Focus event escape sequences leak as literal text in tmux with Option+N keybindings
Bug Description
Title: Focus event escape sequences leak as literal text when using Option+N to switch tmux windows
Description:
When using Option+[1-9] keybindings to switch between tmux windows, the focus event escape sequences [I and [O occasionally appear as literal text input in the terminal.
Root cause:
The tmux-sensible plugin enables focus-events on by default. When switching windows via Option+N, the terminal sends focus lost (\e[O) and focus gained (\e[I) sequences.
Due to timing, these sequences sometimes arrive while the shell is in a state where they're interpreted as literal input rather than control sequences.
Reproduction:
- Use tmux with focus-events on (default in tmux-sensible)
- Bind M-[1-9] to select-window -t N
- Rapidly switch between windows using Option+number
- Observe [I or [O appearing at the prompt or in editor buffers
Suggested improvement:
Claude Code could detect when users have focus-events enabled in their tmux config and proactively warn about this interaction, or suggest adding readline bindings to
neutralize the sequences:
\# ~/.inputrc
"\e[I": ""
"\e[O": ""
Alternatively, documentation could note this as a known quirk when using meta-key window switching with focus-events enabled.
Environment Info
- Platform: darwin
- Terminal: tmux
- Version: 2.0.50
- Feedback ID: 83fb8f9b-a533-42ce-9a8a-f8cb08efa477
Errors
[]This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗