If you want copy-paste to work between tmux and other apps, you are given instructions to use a rather complicated setup, plugins, forward X11 with ssh (what about Wayland?).

A more simple way is to use a terminal that supports OSC 52 control sequences. The more common terminals such as konsole and gnome-terminal do not support them, because they can be a security concern (an application running on the terminal “stealing” your clipboard). On the other hand they are too convenient to pass…

Some terminals that do support OSC 52 are xterm (with a configuration option) and alacritty.

Alacritty is an OpenGL accelerated terminal emulator written in Rust. It doesn’t support tabs and I think it is intended to be used either with a terminal multiplexer such as tmux and screen or with i3. It is cross platform, supporting all major platforms. On Linux, you can get it from your distribution’s package manager. On Windows and MacOS, you can grab the binaries.

In any case, all you need is these options in ~/.tmux.conf:

set -g default-terminal "tmux-256color"
set -g mouse on

And then use the mouse to select a region. It will be copied to clipboard.

Special considerations for ssh connections

  • If you are using Debian on the remote, make sure ncurses-term is installed, to provide the extra terminal definitions that include alacritty. In Ubuntu, it should be already installed.
  • Some older distributions such as Debian buster did not yet include terminfo entries for alacritty. In that case you can configure alacritty to use TERM=xterm-256color instead of TERM=alacritty, by adding these lines to alacritty’s configuration file ~/.config/alacritty/alacritty.yml:
env:
  TERM: xterm-256color

Making it more comfortable

You can choose a color scheme here. In my case, I picked Breeze. I clicked on its arrow and copy-pasted the scheme in a file called ~/.config/alacritty/breeze.yml.

I also like F11 to toggle full screen. Putting it altogether, append these lines to ~/.config/alacritty/alacritty.yml:

import:
 - ~/.config/alacritty/breeze.yml

key_bindings:
  - { key: F11, action: ToggleFullscreen }