I'm using tmux
and OSX. When copying and pasting from the terminal with tmux
I'm able to hold down Option
and select text. However I can't get the text to stay inside the pane. So when I want to copy text I either need to cycle the pane to the far left, or zoom the pane, as shown below.
This in addition to having to hold down the Option
key is a pain. I know I can enter visual mode and use vim movements to get there, but I'd rather have a way to use my mouse. Has anyone found a workaround for this?
Best Answer
Put this block of code in your
~/.tmux.conf
. This will enable mouse integration letting you copy from a pane with your mouse without having to zoom.After that, restart your tmux session. Highlight some text with mouse, but don't let go the mouse. Now while the text is stil highlighted and mouse pressed, press return key. The highlighted text will disappear and will be copied to your clipboard. Now release the mouse.
Apart from this, there are also some cool things you can do with the mouse like scroll up and down, select the active pane, etc.
If you are using a newer version of tmux on macOS, try the following instead of the one above:
If using iTerm on macOS, goto iTerm2 > Preferences > “General” tab, and in the “Selection” section, check “Applications in terminal may access clipboard”.
And if you are using Linux and a newer version of tmux, then
In Debian and Debian based distros (Ubuntu, Kali), you might need to install
xclip
:(You may also check out https://github.com/gpakosz/.tmux for many other tmux options.)