A robust solution that works with any combination of mosh + tmux + vim + nested sessions
After spending many days tackling this, by far the most robust solution I've discovered is Suraj N. Kurapati's posted solution. The solution works locally with (and without) tmux v3.2 and/or vim, as well as remotely with (and without) tmux and/or vim, using both copy-mode keys and simple mouse selection.
If combined with Mike Gulick's (currently open) pull request, all of these combinations work with mosh as well.
Until Mike's solution is merged into mosh, you can pull his changes and build locally using:
Ubuntu:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0 \
&& sudo apt-add-repository https://cli.github.com/packages \
&& sudo apt update \
&& sudo apt install -y gh autoconf automake perl protobuf-compiler libprotobuf-dev libncurses-dev zlib1g-dev libutempter-dev libssl-dev pkg-config \
&& mkdir -p ~/tmp/mosh \
&& git clone https://github.com/mobile-shell/mosh ~/tmp/mosh \
&& cd ~/tmp/mosh \
&& gh pr checkout 1104 \
&& ./autogen.sh \
&& ./configure \
&& make \
&& sudo make install
macOS:
I think you need to install Apple's Xcode/Developer Command Line Tools first (which, IIRC, can now be done by simply running gcc
and exiting), then running:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" \
&& brew install gh autoconf automake
&& mkdir -p ~/tmp/mosh \
&& git clone https://github.com/mobile-shell/mosh ~/tmp/mosh \
&& cd ~/tmp/mosh \
&& gh pr checkout 1104 \
&& ./autogen.sh \
&& ./configure \
&& make \
&& sudo make install
With these updates, the clipboard holy grail has finally been achieved!
However, this is very new information, thus this post of mine is rather volatile. Therefore:
Please kindly revise my post if:
- I'm missing dependencies, etc, or
- Performing a
gh pr checkout 1104
of Mike's changes is no longer needed because it's been merged into mosh, or
- Building from source is no longer needed because the merged changes have been pushed to brew/apt/etc package managers.