Skip to content

fix: write Alt+Enter through zellij as CSI-u - #265

Merged
filipeforattini merged 1 commit into
mainfrom
alt-enter-csi-u
Sep 25, 2026
Merged

filipeforattini merged 1 commit into
mainfrom
alt-enter-csi-u

Conversation

@filipeforattini

@filipeforattini filipeforattini commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Why

red-dev runs zellij with support_kitty_keyboard_protocol false, so zellij forwards Alacritty's Alt+Enter to the pane as a bare ESC CR. Pane apps cannot tell that apart from Escape followed by Enter, or from the ESC CR some 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 the shared_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 binds M-C-m/M-RET to newline and decodes CSI 13;3u natively as M-RET (checked in the installed ble.sh). Plain readline had ESC CR unbound, so it now matches ble.sh.
  • src/dotfiles.ts: new shipped hash (d72b81…) added to SHIPPED_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 a config.user.kdl layer (composed configs) are regenerated on every converge anyway.
  • Tests: new src/alt-enter.test.ts (zellij binding in the shared block, survives a user layer, inputrc mapping). src/zellij-config-upgrade.test.ts pins that the 1.0.169 config is dc5ea3… and upgrades, and the HOME-independent test now also strips the Alt+Enter paragraph.
  • README: one paragraph in the input-gestures section.

Agents: what they receive now

Claude Code and Codex now receive CSI 13;3u for Alt+Enter instead of ESC CR.

  • Codex (crossterm): crossterm always decodes CSI-u, even without the kitty flags pushed, and turns 13;3u into Enter + ALT. It decodes ESC CR into the same KeyEvent, so nothing changes for Codex.
  • Claude Code (Ink-based parser): it already receives CSI 13;2u for 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.
  • RedCode: input_newline already lists alt+return, and opentui decodes CSI-u modifiers.

Validation

Ran locally: bun test on 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 --noEmit is clean. CI runs the full suite.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

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.
@filipeforattini
filipeforattini merged commit 4e9dce6 into main Sep 25, 2026
4 checks passed
@filipeforattini
filipeforattini deleted the alt-enter-csi-u branch September 25, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant