Skip to content

Instantly share code, notes, and snippets.

@bigFin
Created March 10, 2025 17:33
Show Gist options
  • Save bigFin/b6c2e562583e74da646b42747674a3ba to your computer and use it in GitHub Desktop.
Save bigFin/b6c2e562583e74da646b42747674a3ba to your computer and use it in GitHub Desktop.
init.lua chunk to fix nvim clipboard when on ssh
vim.opt.clipboard:append("unnamedplus")
-- OSC 52 clipboard provider
local function copy(lines, _)
local text = table.concat(lines, "\n")
vim.fn.chansend(vim.v.stderr, "\x1b]52;c;" .. vim.base64.encode(text) .. "\x07")
end
local function paste()
local content = vim.fn.getreg('"')
return vim.split(content, "\n")
end
-- Set the clipboard provider only when over SSH
if vim.env.SSH_TTY then
vim.g.clipboard = {
name = "OSC 52",
copy = {
["+"] = copy,
["*"] = copy,
},
paste = {
["+"] = paste,
["*"] = paste,
},
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment