Skip to content

Instantly share code, notes, and snippets.

@KaminariOS
Created November 30, 2025 22:41
Show Gist options
  • Select an option

  • Save KaminariOS/26bffd2f08032e7b836a62801d69b62a to your computer and use it in GitHub Desktop.

Select an option

Save KaminariOS/26bffd2f08032e7b836a62801d69b62a to your computer and use it in GitHub Desktop.
Nvim copy over SSH(osc 52)
-- 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