‹ Guides

Term's mosh server, made for coding agents v26.7.0+

Mosh keeps your session alive on a moving phone. termosh is Term's own mosh server, and it also keeps Claude Code, Codex and other agents looking and behaving the way they do on a desktop.

Available in Term v26.7.0 and later.

Part of Term Pro from 26.7.0.

Written

Why a mosh server of our own

Mosh is the best way to keep a terminal session on a phone. Walk out of Wi-Fi, lock the screen, ride the subway, and the session is still there when you look again. But the server half of mosh was written long before coding agents. Run Claude Code or Codex through it and things go subtly wrong: colours that do not match your screen, an agent that hesitates before it starts, a reply that flickers in half-drawn, a Shift+Enter that sends instead of starting a new line.

termosh is Term's own mosh server. It speaks the same language as mosh, so the session keeps everything mosh is good at, and it was built from the start to keep coding agents right.

Your theme, even when you change it

Coding agents pick their colours to suit your screen: dark text on a light background, light text on a dark one. They ask the terminal which one you are using. With ordinary mosh the answer is decided when you connect and never changes, so if you switch Term between light and dark mid-session, the agent keeps painting for the screen you had before.

With termosh, Term tells the server every time you switch, and the agent repaints in the new scheme straight away.

ordinary mosh Claude Code over ordinary mosh after switching Term from light to dark: the prompt bar is still white, the added lines sit in a pale green box, and the line of code below them is dark blue on a near-black background.
Ordinary mosh: the session started in light mode and Term was then switched to dark. Claude Code still draws its light theme, so the prompt bar glares white and the code line under the change is dark blue on black and hard to read.
termosh The same task over termosh after the same switch: a dark prompt bar, the added lines on dark green, and the code in bright, readable colours.
termosh: the same task and the same switch. Claude Code noticed the change and repainted in its dark theme on its own: dark prompt bar, dark green for the added lines, every line readable.

Agents start straight away

A coding agent asks the terminal a handful of questions as it starts: which terminal is this, is the background light or dark, which keyboard mode, can it draw a whole screen at once. Some give up after a fraction of a second. Ordinary mosh leaves them unanswered, so the agent waits, then starts with features switched off. termosh answers every one on the spot.

ordinary mosh The four startup questions over ordinary mosh, each with 'no answer, gave up after 2 s'.
Ordinary mosh: none of the four questions is answered. The agent waits two seconds on each, then carries on without knowing.
termosh The same four questions over termosh, each 'answered in 0 ms'.
termosh: every question answered at once, so the agent starts with everything it can use turned on.

Replies redraw cleanly

That last question matters most while an agent is answering: it redraws the screen many times a second. termosh says yes, holds each picture until it is complete, and sends it whole, so you never see a half-drawn frame.

Shift+Enter starts a new line

In Claude Code's prompt, Shift+Enter adds a line instead of sending the message, the same as on a desktop.

When a program prints a link, termosh passes it on, and a tap offers to open it. Over ordinary mosh the same words arrive as plain text.

A link printed by a program over termosh; tapping it shows Open link? with the address and Copy and Open buttons.
termosh: tap the link and Term offers to open or copy the address. Over ordinary mosh the same line is plain text and the tap does nothing.

Every underline style

Agents and editors underline with meaning: a curly red line under an error, a dotted one under a hint. Ordinary mosh only knows the plain underline and drops the rest.

ordinary mosh Five underline styles over ordinary mosh: only the first is underlined.
Ordinary mosh: only the plain underline survives. The curly, double, dotted and dashed ones are gone.
termosh The same five styles over termosh: plain, curly red, double, dotted blue and dashed.
termosh: all five arrive, colours included.

The cursor shape the program asks for

Editors and agents change the cursor to tell you what mode you are in: a thin bar while you type in vim, a block when you move around. Ordinary mosh ignores the request and keeps the block. termosh passes it on, and Term keeps it when you switch tabs and come back.

ordinary mosh A program asked for a bar cursor over ordinary mosh: the cursor is still a block.
Ordinary mosh: the program asked for a bar, and the cursor stays a block.
termosh The same request over termosh: a thin bar cursor.
termosh: the thin bar the program asked for.

Long lines rewrap when you resize

Rotate the phone or pinch to change the text size, and the screen gets narrower or wider. termosh rewraps long lines to fit. Ordinary mosh cuts them at the old edge, and the cut-off part is gone.

ordinary mosh A long line over ordinary mosh after making the text bigger: pieces of the line are missing.
Ordinary mosh, after pinching to make the text bigger: the line is cut into pieces and parts of it are lost.
termosh The same line over termosh after the same pinch: all of it, rewrapped to the new width.
termosh, the same pinch: the whole line, rewrapped to the new width.

Copy from tmux reaches your phone

Text you copy inside tmux on the server lands on your phone's clipboard, ready to paste anywhere. Ordinary mosh drops tmux's copies on the way, unless you add a workaround to your tmux settings. Copying the same text twice works too.

Using tmux? By default tmux keeps links and the fancier underlines to itself, and ignores a copy made by a program running inside it. Two lines in ~/.tmux.conf let them through, then detach and attach again:

~/.tmux.conf
set -as terminal-features ',xterm*:hyperlinks:usstyle'
set -g set-clipboard on

Still mosh

Everything mosh does, termosh does: the session survives a network change, a locked screen and a weak signal, and typing still feels instant on a slow link. A host you leave on ordinary mosh-server works exactly as before.

A Term Pro feature

termosh is part of Term Pro. On a host still using ordinary mosh-server, Term's mosh keeps working as it always has.

It is about the agent, not the connection

termosh does not make a slow network faster than mosh does. What it changes is how faithfully your agent's screen arrives on your phone.

References: Customizing mosh · mosh.org