Skip to main content

Terminal session management and multiplexing

2020-06-11 — 2026-10-19

quality 7.1

Wherein Terminal Session Management Is Treated as the Disentangling of Processes From Their Launching Terminal, and the Practice of Detaching Processes to Survive Flaky SSH Sessions Is Described.

computers are awful
faster pussycat
plain text
POSIX
Figure 1

Disentangling the programs you are running from the terminal you launched them in, for recombining and tweaking. What do I even mean?

Typically, we encounter this concept via tmux or the rather ancient screen, which do a lot of stuff at once, making it harder to explain.

The convenience of these tools is sometimes outweighed by the confusion they cause when we do lots of remote SSH work. It was for me.

It seems easy to conflate terminal session management with window management-plus-terminal emulators which is rather a different thing. tmux, for example, includes:

  1. session management (for me, the most important thing), and
  2. keeping a nice, tidy-looking virtual interactive terminal to handle the input and output in that session and switching between sessions

The combination of these things is called a terminal multiplexer and we think about it as a way of smushing several terminal sessions into one network session. That is what people usually pitch to you when selling you, but not always, so I guess bear that in mind. There are two children in the trench coat.

For me, temporarily detaching processes from the launching terminal and resuming control of them later after my crappy internet fell over is the killer feature. Multiple terminals and such are a nice side effect, but I already have many terminals open to the same host because my terminal emulator supports tabs and splits, which means that a lot of the breathless tutorials I run into are confusing when they focus on that feature. I presume the imagined target of such things is someone who has just been unfrozen from suspended animation in an era when all computers were operated by text-only terminals. If we are not that person, and I am not, this can be a weird place to start.

Some terminal session systems have a clear separation of concerns, e.g. in abduco. This seems pedagogically helpful, although I’m not sure if it’s practically helpful. OTOH tmux is ubiquitous, so we probably run into that first, and it does its level best to make these concepts inextricable.

1 Zellij

The new tool everyone is hyped about because it is written in Rust and also because this space is ready for some disruption.

Zellij is a workspace aimed at developers, ops-oriented people and anyone who loves the terminal. Similar programs are sometimes called “Terminal Multiplexers”. […]

Zellij is geared toward beginner and power users alike - allowing deep customizability, personal automation through layouts, true multiplayer collaboration, unique UX features such as floating and stacked panes, and a plugin system allowing one to create plugins in any language that compiles to WebAssembly.

Example quirky bonus feature: The Zellij Web Client - Share Sessions in the Browser

2 abduco+dvtm

abduco is a tool that does strictly #1.

abduco provides session management i.e. it allows programs to be run independently from their controlling terminal. That is programs can be detached - run in the background - and then later reattached.

That is, after I get booted off the server running my slow job, I can get back online later and check its progress without anything going south because of my network embarrassment. But if I’m running an interactive process, I might want that session to include a virtual terminal that keeps track of the state of my screen and I/O and all that stuff. dvtm is the twin to abduco that provides such niceties as clean and reusable screen state.

Now that we’ve used abduco for its pedagogic clarity, let’s do what everyone else does and ignore it in favour of the slightly more confusing tmux, which is well documented, well supported, and ubiquitous, and thus has greater practical advantages over its ideologically and pedagogically purer cousin.

There is a comparison on slant of the tmux and abduco ecosystems.

3 tmux

See tmux.

4 mtm

mtm is an ultra-minimalist tmux replacement. I haven’t worked out which of the various features discussed here it implements.

5 Headless Terminal Multiplexer

As far as I can tell, there’s some kind of standardization battle being waged. HTM is an in-progress (?) terminal-multiplexer standard. Eternal Terminal, and perhaps hyper or possibly microsoft terminal, may at some point support it. It’s supposed to be “more open” than tmux’s control mode, although the documentation is hard to find, so it’s “more open” in an abstract, moral sense rather than in a concrete, actionable way for someone like me. I think the documentation might be this source code snippet?.

If HTM made progress, we could have a system for integrating session managers/multiplexers into the GUI of the hosting terminal emulator in a cross-platform, mutually compatible way. This sounds nice, I suppose, but not nice enough to make me wander into a poorly explained standards quagmire of fringe technologies. I won’t complain if this technology materializes and I get to free-ride on the efforts of others by using it.

6 Wezterm

Wez’s Terminal Emulator seems to support multiplexing. It’s not clear to me what standard, if any, it uses.

7 Tern

Tern is a terminal emulator with a multiplexer built in, from Stencil Labs1. It does both jobs: a session daemon runs the panes and keeps the authoritative copy of each screen, plus every window attaches to the daemon and mirrors it, so closing the window leaves the panes running.

1 It is in closed beta, so this screed is based on its docs, not from use.

USP: the daemon’s session state holds more than a character grid showing the screen of a notional terminal. tmux remembers cells and supports not only the reconstruction of a full-screen program that redraws itself from scratch, but, in the case of a program that speaks Tern’s Surface Protocol, rather a lot more. Apps can maintain their own state and UI structure.

Also, there is some clever flow control such that to even the undrawn app state, the program accumulates its changes while the network is hiccuping. Slow clients therefore see fewer, larger updates instead of a flooded pity.

The cool features are acquired only by programs that speak the protocol, which is only omp and Tern’s own plugins. Also, since it is not actually magic, after a daemon crash, those structured surfaces come back closed and read-only in the scrollback, and full-screen ones not at all.

Other neat features

  • Native windows attached to a mux daemon, rather than a TUI drawing panes inside a terminal as per WezTerm and iTerm2
  • Remote machines run their own daemon (tern remote serve, over QUIC, with SSH or Tailscale to find and authenticate them), and the client does Mosh-style predictive local echo, guessing keystrokes (!) for long lags, similar to Eternal Terminal
  • Supports multiplayer mode and mirroring to a browser tab, similar to Zellij