Filippo Valsorda has a solution for OS X that incorporates iTerm 2, tmux, and mosh.
His solution uses a single window/tab to connect to a remote shell. The shell survives disconnects (e.g., connection failure, IP changes, laptop reboots) and supports scrollback with a touchpad, copy-paste, and colors.
Caveats are that you must build mosh from source, scrolling is less fluid than native, and click-drag is relayed, so you must hold Option to select.
In the Terminal Profile settings, Enable xterm mouse reporting and set Report Terminal Type to xterm-256color.
~/.tmux.confon the server to the following. With these settings, if you try to attach and there are no sessions, a new one is created. The settings also enable mouse interactions (and thus touchpad scrolling).
new-session set-window-option -g mode-mouse on set -g history-limit 30000
Note: On more recent tmux (i.e. > 2.1), as reported by
tmux -V, the various mouse options (mouse-resize-pane, mouse-mode, etc.) have been rewritten to a single option
mouse, so you have to change the second line above to
This mouse scroll will also work when you are in keyboard scroll mode (e.g. Ctrl–b then [), described in the article How to scroll in tmux.
The stable build of mosh is old and does not support mouse reporting (and touchpad scrolling). To install the latest version, do the following:
OS X (your client)
brew install --HEAD mobile-shell
Linux/UNIX (the server)
git clone https://github.com/keithw/mosh.git cd mosh/ sudo apt-get build-dep mosh ./autogen.sh && ./configure && make sudo make install
Now, to connect, just type the following:
mosh HOST -- tmux a
The terminal emulation is baked pretty deep into the design of mosh, so, no. Mosh works by having both client and server each maintain its local idea of what the screen currently “looks like”, and that requires that the server does terminal emulation. This is how the client is able to refresh the contents of the screen after it has been away for a while and lost some data.
I think that an application with the IP roaming feature of mosh but without terminal emulation would end up being quite a different (but simpler) application. For such an application, loss of data (including when the client is off-net for some time) would result in loss or corruption of screen contents. This is an acceptable limitation if the user is using an application where this doesn’t matter much (e.g. shell) or an application which has a repaint feature (e.g.
vi using Control-L).
The implementors of Mosh are planning scrollback support in the application though, to make up for the fact that your local terminal cannot do it anymore. I guess this would have to work a little bit like
screen‘s scrollback buffer though: controlled by keystrokes, not scrollbar and mouse.
Eternal Terminal ( https://mistertea.github.io/EternalTerminal/ ) is an alternative to Mosh that supports native scrollback and still allows IP roaming. ET doesn’t do the typing prediction, so it may not be suitable if you have a high latency connection (if you are ssh-ing into a drone or from a cell phone), but personally ET does everything I want and supports scrollback.