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

Add Shift-Enter support for Ghostty via `/terminal-setup` (with workaround)

Open adamavenir opened this issue 7 months ago • 3 comments

Some terminals get easy modifier-Enter shortcuts just by running /terminal-setup. Ghostty's not one of those. It would be nice if it was at some point.

But it's okay! You can fix this by going to Ghostty > Settings and adding to your config:

keybind = shift+enter=text:\n

adamavenir avatar May 24 '25 06:05 adamavenir

~FWIW, I had to use keybind = shift+enter=text:\\\r\n to get shift+enter to send \<CR> to claude code to get a newline due to running a terminal in Neovim. Not sure if there's a standard way that would work across raw shells, neovim terminal, or other multiplexers. 🤔~

Err, seems like this is some oddity of https://github.com/greggh/claude-code.nvim terminals. Disregard; text:\n works fine in normal nvim :terminal windows (as well as non-nvim ghostty windows).

garrett-hopper avatar May 25 '25 20:05 garrett-hopper

TIL about claude-code.nvim! thanks @garrett-hopper

adamavenir avatar May 26 '25 01:05 adamavenir

strangely, after running /terminal-setup my ghostty config did have that keybind, but it wasn't working even after restarting ghostty and manually reloading the config. I had to add double quotes around the \n to get it working:

keybind = shift+enter=text:"\n"

Traviskn avatar Jun 18 '25 03:06 Traviskn

My ghostty with keybind = shift+enter=text:"\n" and with keybind = shift+enter=text:\n seems to want to enter doublequote pairs when i hit shift+enter

» "
\ ""
\ ""
\ ""
\ ""
\ "
------------

jmherbst avatar Aug 13 '25 18:08 jmherbst

My ghostty with keybind = shift+enter=text:"\n" and with keybind = shift+enter=text:\n seems to want to enter doublequote pairs when i hit shift+enter

» "
\ ""
\ ""
\ ""
\ ""
\ "
------------

Yes I'm also getting the extra double quotes, shift enter is not really usable in ghostty due to this 😔

Traviskn avatar Aug 13 '25 19:08 Traviskn

FWIW, this worked for me (esc + cr):

keybind = shift+enter=text:\x1b\r

aud avatar Aug 13 '25 20:08 aud

For anyone using ghostty+tmux this worked for me. In ~/.config/ghostty/config add:

keybind = shift+enter=text:\\\n\r

humberaquino avatar Aug 16 '25 13:08 humberaquino

FWIW, this worked for me (esc + cr):

keybind = shift+enter=text:\x1b\r

Thanks this works great for me! No more extra double quotes 🎉

Traviskn avatar Aug 18 '25 18:08 Traviskn

Ghostty sending the escape sequence [27;2;13~ is actually pretty nice (and arguably richer than sending just \n because it conveys more information).

It breaks down as:

[27;2;13~ = modifier(2=Shift) + key(13=Enter)

Ideally Claude Code should recognize this standard escape sequence as well as a regular \n input. If Claude Code would recognize this, no hacks/workarounds in Ghostty configs would be needed for anyone.

nvie avatar Aug 19 '25 20:08 nvie

It'll be fixed in an upcoming release, thanks for raising!

km-anthropic avatar Aug 22 '25 19:08 km-anthropic

FWIW, this worked for me (esc + cr):

keybind = shift+enter=text:\x1b\r

Just to +1 that this is what worked for me in Ghostty + tmux + nvim + coder/claudecode nvim plugin.

dpehrson avatar Aug 22 '25 23:08 dpehrson

FWIW, this worked for me (esc + cr):

keybind = shift+enter=text:\x1b\r

Please do not let CC silently add this automatically; it breaks other programs. https://github.com/sst/opencode/issues/1505

esafak avatar Sep 29 '25 21:09 esafak

Linux Claude just added that keybind but I get (#9549) [27;2;13~ too. claude 2.0.15 doesn't recognise that

mattgodbolt avatar Oct 14 '25 23:10 mattgodbolt

Ghostty sending the escape sequence [27;2;13~ is actually pretty nice (and arguably richer than sending just \n because it conveys more information).

It breaks down as:

[27;2;13~ = modifier(2=Shift) + key(13=Enter)

Ideally Claude Code should recognize this standard escape sequence as well as a regular \n input. If Claude Code would recognize this, no hacks/workarounds in Ghostty configs would be needed for anyone.

I agree. Not recognizing [27;2;13~ is a bug in Claude Code that Anthropic should fix from their end. Users shouldn't put stuff like keybind = shift+enter=text:\n in their Ghostty config as that could break other programs.

It'll be fixed in an upcoming release, thanks for raising!

@km-anthropic It's November now. I hope the fix will be released soon!

nalzok avatar Nov 07 '25 09:11 nalzok