Mosh scrollback is incomplete, and how to use the mouse
Why you cannot scroll back through everything in a Mosh session, how tmux or screen on the host gives you history, and what Mosh supports for mouse input.
In a Mosh session you cannot scroll back to see all of the earlier output the way you can in a plain SSH session. This is a design limit of Mosh, not a fault in your connection.
Why
The Mosh FAQ answers the question "Why is my terminal's scrollback buffer incomplete?" directly: Mosh synchronizes only the visible state of the terminal. The text that has already scrolled off the screen is not sent to your device.
The FAQ gives one workaround for now: use screen or tmux on the remote side.
Get history with tmux
Start tmux on the host and let it keep the history. Run it inside Mosh like this:
mosh [email protected] -- tmux new-session -A -s main
Then use tmux's own copy mode to scroll up and search. See Scroll back and search history in tmux, and Keep your work after a disconnect with tmux for the full command.
If the output is long
Do not rely on the screen for output you need later. Send it to a file, or page it:
long-command | less
long-command > output.txt
The mouse
The Mosh news page says that Mosh 1.2.5, released in July 2015, added support for mouse modes. Mouse events reach a program in the session only when that program asks for them. In tmux, the mouse option does this: when it is on, tmux captures the mouse and allows mouse events to be bound as key bindings.
tmux set-option -g mouse on
Mouse modes came in Mosh 1.2.5. If the mouse does nothing in a session, check that the Mosh on the host is that version or newer, and that the program is set to use the mouse.
Related
- How Mosh works
- Mosh or SSH?
- A detached Mosh session on the server
- Text copied from a Mosh session pastes as one long line with spaces