Terminal session management and multiplexing
2020-06-11 — 2025-10-15
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.
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:
- session management (for me, the most important thing), and
- 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 one that everyone is hyped about because it is 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 designed around the philosophy that one must not sacrifice simplicity for power, taking pride in its great experience out of the box as well as the advanced features it places at its users’ fingertips.
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 which 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, there could be 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 materialises and I get to free-ride on the efforts of others by using it.
Wez’s Terminal Emulator seems to support multiplexing. It’s not clear to me what standard, if any, it uses.