Add Shift-Enter support for Ghostty via `/terminal-setup` (with workaround)
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
~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).
TIL about claude-code.nvim! thanks @garrett-hopper
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"
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
» "
\ ""
\ ""
\ ""
\ ""
\ "
------------
My ghostty with
keybind = shift+enter=text:"\n"and withkeybind = shift+enter=text:\nseems 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 😔
FWIW, this worked for me (esc + cr):
keybind = shift+enter=text:\x1b\r
For anyone using ghostty+tmux this worked for me.
In ~/.config/ghostty/config add:
keybind = shift+enter=text:\\\n\r
FWIW, this worked for me (esc + cr):
keybind = shift+enter=text:\x1b\r
Thanks this works great for me! No more extra double quotes 🎉
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.
It'll be fixed in an upcoming release, thanks for raising!
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.
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
Linux Claude just added that keybind but I get (#9549) [27;2;13~ too. claude 2.0.15 doesn't recognise that
Ghostty sending the escape sequence
[27;2;13~is actually pretty nice (and arguably richer than sending just\nbecause 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
\ninput. 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!