NeoVim plugin that lets you copy and paste to a different tmux pane.
Or, you can just copy to the tmux buffer for later.
With lazy.nvim,
{
"kiyoon/tmux-send.nvim",
keys = {
{
"-",
function()
require("tmux_send").send_to_pane()
-- (Optional) exit visual mode after sending
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<esc>", true, false, true), "x", true)
end,
mode = { "n", "x" },
desc = "Send to tmux pane",
},
{
"_",
function()
require("tmux_send").send_to_pane({ add_newline = false })
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<esc>", true, false, true), "x", true)
end,
mode = { "n", "x" },
desc = "Send to tmux pane (plain)",
},
{
"<space>-",
function()
require("tmux_send").send_to_pane({ count_is_uid = true })
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<esc>", true, false, true), "x", true)
end,
mode = { "n", "x" },
desc = "Send to tmux pane w/ pane uid",
},
{
"<space>_",
function()
require("tmux_send").send_to_pane({ count_is_uid = true, add_newline = false })
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<esc>", true, false, true), "x", true)
end,
mode = { "n", "x" },
desc = "Send to tmux pane w/ pane uid (plain)",
},
{
"<C-_>",
function()
require("tmux_send").save_to_tmux_buffer()
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<esc>", true, false, true), "x", true)
end,
mode = { "n", "x" },
desc = "Save to tmux buffer",
},
},
},
5- will paste selection (or current line) to the .5 pane.5<space>- will paste selection (or current line) to the %5 pane.set -g pane-border-format "#D" in the tmux.conf to see the pane unique identifier.12- will paste selection (or current line) to window 1 pane 2.123- will paste selection (or current line) to window 12 pane 3.<C-_> to copy into the tmux buffer. You can paste using Prefix + ]-) will use the previous pane again.# Set the base index for windows to 1 instead of 0.
set -g base-index 1
# Set the base index for panes to 1 instead of 0.
setw -g pane-base-index 1
# Show pane details.
set -g pane-border-status top
set -g pane-border-format ' .#P (#D) #{pane_current_command} '
If using the example key bindings above, it is recommended to change Nvim-Tree's keybinding (remove '-' and use 'u' instead):
local function nvim_tree_on_attach(bufnr)
local api = require "nvim-tree.api"
api.config.mappings.default_on_attach(bufnr)
local function opts(desc)
return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
vim.keymap.set("n", "u", api.tree.change_root_to_parent, opts "Up")
vim.keymap.set("n", "-", "", { buffer = bufnr })
vim.keymap.del("n", "-", { buffer = bufnr })
end
require("nvim-tree").setup({
on_attach = nvim_tree_on_attach,
-- ...
})
If using the example key bindings above, it is recommended to change oil.nvim's keybinding (remove '-' and use 'U' instead):
require("oil").setup({
keymaps = {
["g?"] = { "actions.show_help", mode = "n" },
["<CR>"] = "actions.select",
["<C-s>"] = { "actions.select", opts = { vertical = true } },
["<C-h>"] = { "actions.select", opts = { horizontal = true } },
["<C-t>"] = { "actions.select", opts = { tab = true } },
["<C-p>"] = "actions.preview",
["<C-c>"] = { "actions.close", mode = "n" },
["<C-l>"] = "actions.refresh",
-- ["-"] = { "actions.parent", mode = "n" },
-- ["_"] = { "actions.open_cwd", mode = "n" },
["U"] = { "actions.parent", mode = "n" },
["`"] = { "actions.cd", mode = "n" },
["g~"] = { "actions.cd", opts = { scope = "tab" }, mode = "n" },
["gs"] = { "actions.change_sort", mode = "n" },
["gx"] = "actions.open_external",
["g."] = { "actions.toggle_hidden", mode = "n" },
["g\\"] = { "actions.toggle_trash", mode = "n" },
},
use_default_keymaps = false,
})