Now tmux, mosh and iTerm2 support the OSC 52 sequence that enables clipboard sharing. However, there is a trap that prevents them from working together.
Mosh accepts OSC 52 sequences with the c;
option. However, tmux doesn't send that option when it emits OSC 52 sequences, which means you cannot use tmux and mosh together with the default configuration.
You can override the OSC 52 sequence generated by tmux by adding the following line to your tmux.conf.
set-option -ag terminal-overrides ",xterm-256color:Ms=\\E]52;c;%p2%s\\7"
Instead of using the default Ms
sequence Ms=\\E]52;%p1%s;%p2%s\\7"
, whose %p1%s;
is the option part, this configuration forces use c;
as the option value.
Note that xterm-256color
must be replaced with your $TERM
value.
Thanks @popjdh! This works for both tmux 3.4 and 3.3a on my machines.