Fixing Cmd+Enter to Insert Newline in Hermes TUI Under Kitty

tech-brief · 85% AI

Fixing Cmd+Enter to Insert Newline in Hermes TUI Under Kitty

Problem

In the Hermes TUI (and other prompt_toolkit-based CLIs like Claude Code), pressing Cmd+Enter in Kitty terminal triggers Kitty’s default new_os_window action, opening a new terminal window instead of inserting a newline in the prompt.

The desired behavior: Cmd+Enter inserts a newline (same as in browser form fields), and Enter alone submits the prompt.

Root Cause

Kitty intercepts Cmd+Enter at the terminal level before it reaches the foreground application. The default mapping opens a new OS window. The application never sees the keypress.

Fix

Add one line to ~/.config/kitty/kitty.conf:

map cmd+enter send_text all \e\n

This overrides Kitty’s default and sends Escape + newline (\e\n) to the foreground process. prompt_toolkit interprets \n (0x0a) as “insert newline” in multiline mode, and submits only on \r (0x0d, carriage return – what plain Enter sends).

Verification

Tested using Kitty’s remote control API:

  1. Launch a fresh Kitty instance with allow_remote_control yes
  2. Run cat -v in the foreground
  3. Send cmd+enter via kitty @ send-key cmd+enter
  4. Confirm: foreground process receives \n, no new window created

Requirements

What Does NOT Work

Attempt Result
disable_enhanced_keyboard_protocol all Kitty 0.46.1 does not recognize this option
disable_enhanced_keyboard_protocol hermes Not a valid option; also, hermes is a python3 script so kitty sees python3 as the process name
map cmd+enter send_text all \r\n \r\n submits the prompt in most TUIs
map cmd+enter combine \e \n combine merges kitty actions, not raw bytes
Config reload only (Cmd+Shift+F5) cmd modifier mappings require full restart

Alternative: Ctrl+J

If Cmd+Enter cannot be remapped, Ctrl+J sends a literal \n (0x0a) that prompt_toolkit interprets as “insert newline.” This works without any kitty config changes.

[No columns defined in frontmatter]


Want to stay in touch? You can reach me in a variety of ways from my Contact page.