claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] iTerm2 keybinding for shift+enter breaks shift+enter in other programs running in iTerm2

Open ku1ik opened this issue 9 months ago • 3 comments

Environment

  • Platform (select one):
    • [x] Anthropic API
    • [ ] AWS Bedrock
    • [ ] Google Vertex AI
    • [ ] Other:
  • Claude CLI version: 0.2.53 (Claude Code)
  • Operating System: macOS 15.3.2
  • Terminal: iTerm2 3.5.11

Bug Description

The terminal setup command, which installs a keybinding for Shift+Enter in iTerm2 config breaks Shift+Enter in other terminal programs, such Neovim, yazi, helix editor.

Claude Code runs the following command to install the Shift+Enter keybinding:

defaults write com.googlecode.iterm2 GlobalKeyMap -dict-add 0xd-0x20000-0x24 '<dict><key>Text</key><string>\\n</string><key>Action</key><integer>12</integer><key>Version</key><integer>1</integer><key>Keycode</key><integer>13</integer><key>Modifiers</key><integer>131072</integer></dict>'

Steps to Reproduce

Reproduce with Neovim:

  1. perform terminal setup via claude, or run the above setup command directly
  2. launch nvim
  3. press : to enter command mode
  4. type imap <S-Enter> hello and press enter
  5. press i to enter insert mode
  6. press shift+enter
  7. notice a new line is added, while "hello" should have been inserted into the buffer
  8. remove the iTerm2 keybinding (Settings -> Keys -> Key Bindings)
  9. press shift+enter
  10. notice "hello" is inserted into the buffer

Reproduce with Yazi:

  1. perform terminal setup via claude, or run the above setup command directly
  2. launch yazi
  3. select a file by pressing space
  4. press shift+enter (this keybinding is a default one, documented here https://yazi-rs.github.io/docs/quick-start)
  5. notice the file is opened immediately in a default associated program ($EDITOR)
  6. remove the iTerm2 keybinding (Settings -> Keys -> Key Bindings)
  7. press shift+enter
  8. notice yazi displays "Open with" popup, as expected

Expected Behavior

Claude Code's terminal setup doesn't break Shift+Enter behavior in other terminal programs.

Actual Behavior

Claude Code's terminal setup breaks Shift+Enter behavior in other terminal programs.

Additional Context

Neovim, Yazi, and increasing number of CLI programs use Kitty keyboard protocol for advanced keyboard shortcuts. By mapping Shift+Enter to "\n" (what you do here) you're preventing actual Shift+Enter sequence (kitty protocol encoded) from hitting any program running in iTerm2. I strongly suggest using a different approach for claude under iTerm2.

ku1ik avatar Mar 25 '25 10:03 ku1ik

Any updates on this bug plz? 🙏 iterm2 key bindings become useless after installing claude!

moodiRealist avatar Aug 23 '25 17:08 moodiRealist

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] avatar Dec 05 '25 10:12 github-actions[bot]

Still occuring.

ku1ik avatar Dec 05 '25 11:12 ku1ik