Kitty keyboard protocol not popped on exit (Ghostty, macOS)

Resolved 💬 4 comments Opened Mar 25, 2026 by sgrankin Closed Mar 29, 2026

Bug Report

Version: Claude Code 2.1.83
Terminal: Ghostty (macOS, Darwin 25.4.0)
Shell: zsh

Problem

Claude Code pushes the Kitty keyboard protocol (level 1) multiple times during a session but does not pop them all on exit. After exiting Claude Code, Ctrl-D stops working in the shell (rings the bell instead of sending EOF).

Diagnosis

  • stty -a looks clean after exit — eof = ^D is set, all flags normal
  • printf '\e[?u' (Kitty keyboard protocol query) shows ^[[?1u — protocol still active at level 1
  • A single printf '\e[<u' (pop) was not sufficient — multiple pops were needed before Ctrl-D worked again, indicating the protocol was pushed multiple times without corresponding pops on exit

Expected behavior

Claude Code should pop all Kitty keyboard protocol levels it pushed when exiting, restoring the terminal to its prior state.

Workaround

Added to .zshrc:

precmd_pop_kitty_kb () { printf '\e[<99u' }
precmd_functions+=( precmd_pop_kitty_kb )

This aggressively pops the protocol stack on every prompt.

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗