The "correct" or "complete" answer some of the above, and at the same time none of the above :) This is the logic:
The logic
In Tmux you can activate mouse by adding either of set -g mouse on
or set-option -g mouse
(add it to your tmux config file ~/.tmux.conf
). This far, have bee explained by others as well.
Now, here is the deal, if you hold Shift and select the text, and then Ctrlc, it will copy it to the same machine that you have the terminal in. This does not respect the tmux splits as it is your terminal that is handling the selection. If you select the text without holding Shift, then you are using tmux to select the text for you (alternatively you can manually select the text (read the end of this post)). This way the selection would respect the panes and splits, but it will copy the selection in the clipboard of the machine that is running tmux.
In other words, if you use computer1 SSH into a computer2 and run tmux there, holding Shift will not respect tmux panes but copies the text in the clipboard of computer1. But if you don't hold Shift, the selection respects tmux panes but the selection goes to clipboard of computer2.
So to save yourselft some headache, the easiest way is to "zoom" the pane you are interested in (Ctrlb then z), hold shift to select the text, copy (usually CtrlShiftc) and then toggle back the zoom (Ctrlb then z).
Keyboard-driven selection and copy
- Enter selction mode by Ctrlb then [
- use the keybinding you set by the
status-keys
(e.g mine is set -g status-keys emacs
which means I use Emacs bindings: Ctrln for down, Ctrlp for up, CtrlSpace to start selection, and so on)
- when selection is done, press your set key to copy (in my case in Emacs mode it Altw)
- to paste use Ctrlb then ]
tmux
version are you using, and which terminal emulator? – JigglyNaga Oct 31 '18 at 16:34