neovim OSC52 yank not working out of box because iTerm isn't sending the correct response to XTGETTCAP
Bug report
Thanks for filing an issue! Please answer the questions below so I can help you.
- iTerm2 version: Build 3.5.3
- OS version: 14.5 (23F79)
- Attach
~/Library/Preferences/com.googlecode.iterm2.plisthere (drag-drop from finder into this window) - Attach a debug log, if possible.
- Attach a screen capture video if it would make the reproduction steps clearer.
PLEASE ATTACH YOUR PLIST FILE FOR BUG REPORTS! Seriously! I'll probably ask you for it if you don’t.
Detailed steps to reproduce the problem
In neovim, yank should copy using OSC52 if the following conditions are correct
- Nvim is running in the TUI
- g:clipboard is unset
- 'clipboard' is not set to "unnamed" or "unnamedplus"
- $SSH_TTY is set
Even if these are true. OSC52 yank doesn't work in iTerm. It does work in other terminals like WezTerm.
What happened
For anyone having this issue, run the following in your shell:
printf '\x1bP+q4D73\x1b\'
You should see something very similar to this be printed back:
P1+r4D73=5C455D35323B25703125733B25703225735C303037
Different shells might omit parts of this string, but you should at least get something.
com.googlecode.iterm2.plistiTerm2 shows P0+r, indicating that it does not support OSC 52 (this is wrong, it does support OSC 52 but iTerm is not communicating that information to applications. So this is an iTerm2 bug).
See here https://github.com/neovim/neovim/issues/29504#issuecomment-2226374704