tmux/Q/What is a conceptual overview of how copy paste works in oh-my-tmux with nvim?
What is a conceptual overview of how copy paste works in oh-my-tmux with nvim?
Answer
- AI/Response
The Three Clipboard Layers
tmux's Internal Buffer
- Enter copy mode with
Prefix+[(oh-my-tmux default; some configs usePrefix+Escape) - oh-my-tmux enables vi-style bindings in copy mode:
vto begin selection,yto yank - Yanked text goes into tmux's paste buffer — shared across all windows and sessions of the same tmux server
- Paste anywhere in the same server with
Prefix+] - This means tmux-buffer copy/paste works transparently across sessions and windows without touching the OS clipboard at all
- Enter copy mode with
oh-my-tmux Clipboard Bridge
- oh-my-tmux auto-detects the OS and wires
yin copy mode to also send the selection to the system clipboard: - Controlled in
.tmux.conf.localvia settings likeset -g @copy_use_prefix on - After this bridge is active, yanking in tmux copy mode simultaneously fills both the tmux buffer and the OS clipboard
- On macOS inside Terminal.app or iTerm2, this just works. Inside SSH or nested tmux, you may need
reattach-to-user-namespace(older macOS) or proper$TERM/$TMUXdetection
- oh-my-tmux auto-detects the OS and wires
nvim's Clipboard Register
- By default, nvim yanks (
y,dd, etc.) go to nvim's unnamed register — not the OS clipboard - To yank explicitly to the system clipboard from nvim:
"+y(or"*yfor primary selection) - To make all nvim yanks go to the system clipboard automatically, add to your nvim config:
- With
unnamedplusset,yin nvim ="+y— text lands in both nvim's register and the OS clipboard
- By default, nvim yanks (
Practical Scenarios
Copy in nvim → paste in another tmux window or session
- If
clipboard=unnamedplusis set in nvim: yank normally, thenPrefix+]will not work (that's the tmux buffer, not OS clipboard) - Better path: switch to the target window, enter nvim (or another shell), and paste with
Cmd+V(macOS) orCtrl+Shift+V(Linux terminal) - Alternative: explicitly yank to tmux buffer from nvim using a shell command:
:!echo -n "text" | tmux load-buffer -(awkward) - Cleanest solution: with
clipboard=unnamedpluson and oh-my-tmux's clipboard bridge active, both the OS clipboard and tmux buffer stay in sync —Prefix+]works anywhere in the server after a tmux-mode yank
- If
Copy in tmux copy mode → paste in browser
- Must go through the OS clipboard — the tmux buffer is invisible to the browser
- With oh-my-tmux's clipboard bridge active: yank with
yin copy mode → OS clipboard is filled →Cmd+V/Ctrl+Vin browser works - If the bridge is not active, use mouse-select +
Cmd+C(macOS) to copy directly via the terminal emulator
Copy in nvim → paste in browser
Copy from browser → paste in nvim
Summary Mental Model
Goal Mechanism tmux window → tmux window/session Prefix+[yank →Prefix+]pastetmux → browser oh-my-tmux clipboard bridge → OS clipboard → Cmd+Vnvim → browser "+yin nvim (orclipboard=unnamedplus) →Cmd+Vnvim → other tmux window OS clipboard (via clipboard=unnamedplus) →Cmd+Vor"+pin destinationbrowser → nvim Cmd+Cbrowser →"+pin nvim (orpwithclipboard=unnamedplus)
Recommended Setup for Smooth Interop
- In nvim config:
vim.opt.clipboard = "unnamedplus"— makes nvim always use OS clipboard - Verify oh-my-tmux clipboard bridge is working: yank something in copy mode, then
pbpaste(macOS) in a shell — should print it - With both in place, you effectively have one unified clipboard: yank anywhere, paste anywhere
- In nvim config:
Sources
- AI/Response