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

Resolved 💬 25 comments Opened May 24, 2025 by adamavenir Closed Apr 27, 2026
💡 Likely answer: A maintainer (km-anthropic, contributor) responded on this thread — see the highlighted reply below.

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

View original on GitHub ↗

25 Comments

garrett-hopper · 1 year ago

~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).

adamavenir · 1 year ago

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

Traviskn · 1 year ago

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"

jmherbst · 11 months ago

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

» "
\ ""
\ ""
\ ""
\ ""
\ "
------------
Traviskn · 11 months ago
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 😔

aud · 11 months ago

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

keybind = shift+enter=text:\x1b\r
humberaquino · 11 months ago

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

keybind = shift+enter=text:\\\n\r
Traviskn · 11 months ago
FWIW, this worked for me (esc + cr): `` keybind = shift+enter=text:\x1b\r ``

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

nvie · 11 months ago

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.

km-anthropic contributor · 10 months ago

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

dpehrson · 10 months ago
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.

esafak · 9 months ago
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

mattgodbolt · 9 months ago

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

nalzok · 8 months ago
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!

CarlQLange · 7 months ago

/terminal-setup now appears to work in Ghostty.

rhodes-b · 7 months ago

Like noted above writing to the config file silently is a insane choice, at least notify users what hacky workaround claude code is going to do because you wont support fixterm repr or kitty keyboard protocol like I mentioned here https://github.com/anthropics/claude-code/issues/6190

It just leads to people thinking there is a bug in ghostty https://github.com/ghostty-org/ghostty/discussions/9844

ricklei2777 · 7 months ago

For me, this works:

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

Environment: M1 MacBook Air, macOS Tahoe 26.1, Ghostty 1.2.3.

I’m using Claude Code inside Ghostty, and I just ran /terminal-setup in Claude Code.

FYI, this did not work for me:

keybind = shift+enter=text:\n

In this case, text:\x1b\r behaves like a proper “submit/accept” (Enter) in this context, while text:\n only inserts a literal newline (or gets ignored by the app), so it doesn’t trigger the action I’m trying to bind Shift+Enter to.

passingbreeze · 6 months ago

For me, with macOS Tahoe 26.2, all of solutions from you guys does not work... What can I do?

> /terminal-setup
  ⎿  (Z)=>kO9(Z,A?PLA(B)[A]:void 0,Q)(
               'Found existing Ghostty Shift+Enter key binding. Remove it to continue.',
             )}
     See /Users/a17236/Library/Application Support/com.mitchellh.ghostty/config
vltansky · 6 months ago

Still doesnt work for me

marcindulak · 6 months ago

Shift+Enter newline functionality got enabled in 2.1.0 by default for several terminal types including Ghostty https://github.com/anthropics/claude-code/blob/5aac2b1b6aa23b65cd146b7eac8af30bc858d6eb/CHANGELOG.md?plain=1#L9

However, it may get reverted, since some people on MacOS got used to Option+Enter https://github.com/anthropics/claude-code/issues/16764

sethawright · 5 months ago

pasting my solution in case someone else stumbles and uses ghostty + tmux

# ghostty conf
keybind = shift+enter=text:‰

# tmux conf
bind-key -n ‰ send-keys -H 0a # newline (claude code/codex/etc)
stefan-girlich · 4 months ago

I can reproduce this issue only after switching to the editor (nvim) via Ctrl+G and return. In-session workaround: Close Claude and restart via claude --continue

Ghostty 1.2.3
Claude Code 2.1.45
NVIM 0.11.5

RussBrown00 · 3 months ago

I'm on a mac, ghostly 1.3.1 and the only thing that works for me so that I get a new line in opencode, claude, grok-cli is keybind = shift+enter=text:\n

edit: I am inside of tmux

claude[bot] contributor · 2 months ago

This issue was fixed as of version 2.1.0.

github-actions[bot] · 2 months 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.