Ctrl-D to be removed from the end of session shortcut key

Status Fixed / completed
Maintainer reply ✓ Yes — wolffiex
Activity 12 comments · opened May 5, 2025 · closed May 7, 2025
💡 Likely answer: A maintainer (wolffiex, collaborator) responded on this thread — see the highlighted reply below.

Ctrl-D's "Erase one character" shortcut is a standard text operation on macOS and is used frequently. If this is used to end the session, it will frequently cause unintended session terminations.

Since Ctrl-C is functionally available, I think there is no reason why Ctrl-D must have similar functions assigned.

View original on GitHub ↗

12 Comments

kmcclosk · 1 year ago

Claude Code is for terminal users. Please revisit this change which makes cc unusable for anyone who has muscle memory for this common keyboard sequence. ctrl-d for erase char is standard and default for emacs users, who like myself chose cc over vscode alternatives. agree that the existing ctrl-c twice to exit is superior and did not need to be altered imo.

maltakoji · 1 year ago

It's better because there's the --resume option, but if this operation causes a session to drop, I'll be insane.

conradchu · 1 year ago

+1 ... I have accidentally quit about a dozen sessions with ctrl + d.

According to Claude 3.7:

In the Terminal on macOS (and many other systems): Ctrl+D has two functions: When pressed at an empty line, it sends EOF (End of File) and can exit applications When pressed within text, it deletes the character under the cursor (similar to the Delete key, not Backspace)
danieldeusing · 1 year ago

OK, I want to add one minor issue whihc fits to the context of this issue:

Press Escape to interrupt Claude during any phase (thinking, tool calls, file edits), preserving context so you can redirect or expand instructions. Double-tap Escape to jump back in history, edit a previous prompt, and explore a different direction. You can edit the prompt and repeat until you get the result you're looking for.

This is an amazing feature and I use it all the time, but when I remote connect to my temrinal with my ipad, I have the problem that there is no ESC ...
Can we have the option to map/overwrite some keys / shortcuts in a json config file? That would be great (or is this already available and I do not know?)

kmcclosk · 1 year ago

This one change has made Claude Code absolutely unusable. I am constantly exiting the program accidentally.

tacass · 1 year ago

I'm using Claude Code in an Ubuntu terminal. Many of the lovely bash/emacs line edit commands work as expected except: Kablamo! CTRL-d quits and all my state is gone. Claude had an excellent suggestion when asked about this: "Train yourself to avoid Ctrl-D habit" . Yeah, right.

EDIT: Ok it redeemed itself when I pressed the point:
"You're absolutely right. For bash/emacs users, Ctrl-D is essential for daily editing (delete character forward) and its current implementation as EOF-only in Claude Code is inconsistent with the other line editing commands. This creates a frustrating experience when muscle memory kicks in.

This deserves a proper feature request - the CLI should either implement Ctrl-D for character deletion (matching standard terminal behavior) or provide a way to disable its EOF function."

jordan-brough · 1 year ago

Did something change recently? Within the last month, or more recently?

If this is correct:

Ctrl+D has two functions: When pressed at an empty line, it sends EOF (End of File) and can exit applications When pressed within text, it deletes the character under the cursor (similar to the Delete key, not Backspace)

The first (ctrl+d on an empty line) is fine, imo, and mirrors how many other macOS terminal programs work (e.g. python & ruby CLIs).

But it seems like the second (ctrl+d in the middle of text) got broken sometime recently?
If I press ctrl+d twice in the middle of text, it exits the session instead of just deleting.

This is extremely frustrating since I lose whatever text was in progress. _And_ often I'll be in the middle of typing ctrl+d _more_ than two times (or holding it down) so it will end up quitting claude code, exiting my terminal window, and then going on to exit other terminal windows!

peterkaminski · 1 year ago

I'm experiencing this as a new problem just like other people. Similar to @jordan-brough, second ctrl+d exits the session, and since I'm holding down ctrl+d, Claude quits, then the terminal exits, then other terminal windows with important state start exiting, too.

VERY frustrating, and it makes Claude Code dangerous to use.

  • macOS Sonoma 14.7 M1
  • iTerm2 Build 3.5.13
  • Claude Code 0.2.102
wolffiex collaborator · 1 year ago

This is supposed to work like iPython: ctrl+d deletes forward, for the special case where input is empty it quits
This regressed in v0.2.99
We should have the fix out tomorrow

wolffiex collaborator · 1 year ago

This should be fixed in v 0.2.104

conradchu · 1 year ago

Thank you!!! So it seems I accidentally closed my last session officially yesterday.

github-actions[bot] · 1 year ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.