Terminal left in CSI u keyboard mode after exiting session

Resolved 💬 2 comments Opened Mar 26, 2026 by thexpand Closed Mar 26, 2026

Description

After exiting a Claude Code session, the terminal remains in CSI u (kitty keyboard protocol) mode. This causes raw escape sequences to be printed instead of normal key behavior.

For example, pressing Ctrl+C after exiting prints 9;5u in the terminal instead of sending the interrupt signal.

Steps to reproduce

  1. Open a terminal (zsh on macOS)
  2. Run claude
  3. Exit the session (e.g., /exit or Ctrl+C to quit)
  4. Press Ctrl+C in the now-returned shell prompt
  5. Observe 9;5u printed to the terminal

Expected behavior

The terminal should be fully restored to its previous state on exit, with the CSI u / kitty keyboard protocol disabled.

Actual behavior

The terminal remains in CSI u mode. Keypresses are encoded as CSI u sequences (e.g., Ctrl+C\e[9;5u) and since the shell doesn't understand this encoding, fragments like 9;5u are printed as literal text.

Workaround

Run reset or printf '\e[<u' after exiting to pop the keyboard protocol mode.

Environment

  • Claude Code: 2.1.84
  • Node.js: v24.14.0
  • OS: macOS 14.3.1 (Build 23D60)
  • Terminal: Ghostty 1.3.0-HEAD+bc9be90
  • Shell: zsh

View original on GitHub ↗

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