Terminal session management and multiplexing
June 11, 2020 — February 22, 2024
Disentangling the programs you are running from the terminal you launched them in, for recombining and tweaking. What do I even mean?
Typically, one encounters 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 less onerous than the confusion if we do lots of remote SSH work. It was for me.
For example, it seems easy to confuse 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 on this tool
For me, the idea of temporarily detaching processes from the launching terminal and then resuming control of them later after my crappy internet fell over is the killer feature. Multiple terminals and such are a side effect that I rarely use, which means that a lot of the breathless tutorials focus on features I do not need.
Some terminal session systems have a clear separation of concerns, which is pedagogically useful, e.g. in abduco
, the architecture is much clearer. OTOH tmux
is ubiquitous so you probably run into that first.
1 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.
i.e. after I get booted off the server running my slow job I can get back online and check on its progress later without anything going south because of my network embarrassment. However, if I am running some interactive process I might want that session to contain a nice virtual terminal which keeps track of the state of my screen and IO and all that stuff. dvtm
is the twin to abduco
that provides such niceties as clean and re-usable screen state.
Now that we have used abduco for its pedagogic clarity, let us 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 great practical advantages over its ideologically and pedagogically purer cousin.
There is a comparison on slant of the tmux
and abduco
ecosystems.
2 tmux
See tmux.
3 mtm
mtm is an ultra-minimalist tmux replacement. I have not worked out which of the various features discussed here it implements.
4 Headless Terminal Multiplexer
As far as I can tell there is some kind of standardisation battle being waged. HTM is an in-progress (?) terminal multiplexer standard. Eternal Terminal and possibly hyper and possibly microsoft terminal may at some point support it. It is supposed to be ‘more open’ than tmux
’s control mode, although the documentation does not seem easier to locate, so it must be considered in more open in some abstract moral sense rather than in a concrete actionable sense for someone like me. I think the documentation is this source code snippet?? If HTM were to make progress, there would be a system for integrating various session managers/multiplexers into the GUI of the hosting terminal emulator in a cross-platform and mutually compatible way. This sounds nice I suppose but not nice enough to wander into a poorly explained standards quagmire of fringe technologies. I will not complain if this technology materialises and I am blessed with the chance to free-ride upon the efforts of others by using it.
Wez’s Terminal Emulator seems to support multiplexing. The standard it uses, if any, is not clear to me.