fix: write Alt+Enter through zellij as CSI-u - #265
Merged
Merged
Conversation
With the kitty keyboard protocol off, zellij forwards Alt+Enter as a bare ESC CR that pane apps cannot tell from Escape+Enter or from the ESC CR some terminals send for Shift+Enter. Bind it to ESC[13;3u in the locked and normal modes, map the sequence to a newline in readline (the same newline ble.sh inserts for M-RET), and recognise the 1.0.169 base so untouched configs upgrade.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
red-dev runs zellij with
support_kitty_keyboard_protocol false, so zellij forwards Alacritty's Alt+Enter to the pane as a bareESC CR. Pane apps cannot tell that apart from Escape followed by Enter, or from theESC CRsome terminals send for Shift+Enter (see redcode PR #449's analysis). Shift+Enter and Ctrl+Enter already avoid this by having zellij write their CSI-u sequence.What
config/zellij/config.kdl: in theshared_among "locked" "normal"block,bind "Alt Enter" { Write 27 91 49 51 59 51 117; }(ESC[13;3u: 13 = Enter, 3 = 1 + alt bit).config/bash/inputrc.conf:"\e[13;3u": "\C-q\C-j", so bash inserts a newline and never echoes raw bytes. This keeps the old behavior: inside zellij the prompt is owned by ble.sh, which bindsM-C-m/M-RETtonewlineand decodesCSI 13;3unatively as M-RET (checked in the installed ble.sh). Plain readline hadESC CRunbound, so it now matches ble.sh.src/dotfiles.ts: new shipped hash (d72b81…) added toSHIPPED_ZELLIJ_CONFIGS. The 1.0.169 base (dc5ea3…) was already listed, so untouched configs upgrade, both bare and under the Linux desktop's generated clipboard tail. Machines with aconfig.user.kdllayer (composed configs) are regenerated on every converge anyway.src/alt-enter.test.ts(zellij binding in the shared block, survives a user layer, inputrc mapping).src/zellij-config-upgrade.test.tspins that the 1.0.169 config isdc5ea3…and upgrades, and the HOME-independent test now also strips the Alt+Enter paragraph.Agents: what they receive now
Claude Code and Codex now receive
CSI 13;3ufor Alt+Enter instead ofESC CR.13;3uintoEnter + ALT. It decodesESC CRinto the same KeyEvent, so nothing changes for Codex.CSI 13;2ufor Shift+Enter through this same zellij path, so its parser handles the CSI-u format. I did not check that it maps the alt modifier (3) to meta+return. Risk: if it does not, Alt+Enter would stop inserting a newline in Claude Code. Shift+Enter and Ctrl+Enter still work there.input_newlinealready listsalt+return, and opentui decodes CSI-u modifiers.Validation
Ran locally:
bun teston alt-enter, zellij-config-upgrade, shift-enter, zellij-layer, terminal-input-stack, clipboard, drift-zellij, emoji, generated-configs-parse and terminal-release (all pass).tsc --noEmitis clean. CI runs the full suite.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.