Created
November 30, 2025 22:41
-
-
Save KaminariOS/26bffd2f08032e7b836a62801d69b62a to your computer and use it in GitHub Desktop.
Nvim copy over SSH(osc 52)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Only copy is supported, paste with Ctrl+shift+v | |
| if vim.env.SSH_TTY then | |
| local osc52 = require("vim.ui.clipboard.osc52") | |
| local function copy_reg(reg) | |
| local orig = osc52.copy(reg) | |
| return function(lines, regtype) | |
| -- Write to Vim's internal register | |
| vim.fn.setreg(reg, table.concat(lines, "\n"), regtype) | |
| -- Send OSC52 to local clipboard | |
| orig(lines, regtype) | |
| end | |
| end | |
| vim.g.clipboard = { | |
| name = "OSC 52 with register sync", | |
| copy = { | |
| ["+"] = copy_reg("+"), | |
| ["*"] = copy_reg("*"), | |
| }, | |
| -- Do NOT use OSC52 paste, just use internal registers | |
| paste = { | |
| ["+"] = function() return vim.fn.getreg('+'), 'v' end, | |
| ["*"] = function() return vim.fn.getreg('*'), 'v' end, | |
| }, | |
| } | |
| vim.o.clipboard = "unnamedplus" | |
| end | |
| ``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment