Hacker News new | ask | show | jobs
by TBurette 1902 days ago
To me, copy/paste is a weakness of a workflow using tmux.

With tmux you end up with four distinct copy/paste buffers: the OS, tmux, the shell, vi/emacs. You do get used to the mental gymnastic of juggling all those but it's not ideal.

Same goes with managing the windows of the OS, tmux and vi/emacs.

5 comments

Echoing others: I have the tmux copy/paste mapped to my system pasteboard. Ditto nvim. I do not use the shell buffers.

The cognitive load you are concerned about can be configured away, and for me is a solved problem.

Works great till you want to copy a ton of text. I frequently need to look up some command to dump the tmux scrollback to a local file because I could only get a couple thousand lines from the buffer.

It's the best option I've found, but it's not all smooth sailing for me at least.

Same on macOS with iTerm's Tmux integration, everything just uses the system clipboard buffer seamlessly, even when copying inside tmux on a remote ssh connection.
Oh, yeah. I can't keep multiple clipboards straight. I configure everything to share the OS clipboard (except my shell... but I don't really use my shell's copy buffer since I got in the habit of using ctrl-q).

tmux will copy to your system clipboard by default if your terminal emulator supports the right escape sequences. If it doesn't, then you do need to configure it to shell out to xclip or pbcopy or whatever. It's annoying, but I find it less annoying to configure it than to try to keep multiple copy buffers straight.

FYI, you can use vim's clipboard register * on linux/Mac (might be + on Windows?) to make it use the system clipboard.

(Or `:set clipboard=unnamed`)

I use the vi mode for tmux and my shell (zsh). I configured tmux and neovim to copy into the system clipboard (not for the shell, I did not search to be honest)

Thus to copy I use the y (yield) key, with optional selection keys like iw (in word), t<char> (to <char> included), f<char>( to <char> not included), etc.

But my mouse selection copy works differently between vim and tmux. In vim, when I select text with the mouse I have to press y to copy it. In tmux it is copied without pressing any key. So there is improvement here because often the paste fails after selecting text in vim because I forgot to press the y key.

tmux is what made drop tiling window managers after I realized I was only using tiling in a terminal. (I use Gnome on Linux.)

I realized that the mouse selection automatic copy is due to the tmux yank plugin.
It's three. The shell doesn't do copy-paste, unless you mean the terminal emulator, but then that's copy-paste as in "the OS". This is actually great because you get many more cut buffers this way. There used to be a utility called xcb(1) to manage X11 cut-buffers (yes, there's more than one!), but even so, that requires too much mouse use. With tmux and vi/vim/emacs you get many cut-buffers. If, like me, you run a $EDITOR per-pane, then the tmux cut buffers are most useful when cutting and pasting between panes, while $EDITOR cut buffers are most useful when cutting and pasting within a file.
You can copy and paste in bash and zsh with emacs keybindings (by default). I will sometimes start typing git commit -m "something...", then hit ctrl-a ctrl-k, then stage another file, and then later ctrl-y to finish the commit. But ctrl-q basically does that same thing, in a nicer way. I don't know how to get bash/zsh to integrate with the system clipboard.