top | item 22843789

(no title)

aaronjanse | 5 years ago

Hey HN,

I'm a long-time user of i3 (now sway). I wrote this tool to provide the elegance of i3 to terminal users everywhere, especially for people like myself who sometimes use a non-i3 wm or no window manager at all (e.g. when testing code on a bare-bones raspberry pi).

Cheers!

discuss

order

apjana|5 years ago

In my experiments for a good multiplexer to go with nnn https://github.com/jarun/nnn, I have tried dvtm and tmux. dvtm is extremely light but it appears there's no way to open a new command in a new pane from within a session. This is where tmux trumped.

So if I want to open 2 panes, I run

  dvtm n n # n is aliased to nnn + some program options
But if I want to open text/image files detached in a new pane, my custom opener calls:

  tmux split-window -h "vim \"$*\""
Can 3mux do both for me?

  - present a lightweight multiplexer
  - support options to open split windows and run a command
Note: This is not necessarily i3-specific, please consider cross-DE/WM scenarios.

krat0sprakhar|5 years ago

Looks awesome, thanks for sharing! I've been using Byoyu[0] which has a similar goal, but I'm keen on trying out. Even though I've been a long-time tmux user, as a developer I don't even know where I would start if I wanted to build my own terminal multiplexer. Can you share some resources etc on what could a good starting point if I want to explore this as a side-project?

[0] https://www.byobu.org/

aaronjanse|5 years ago

My understanding is that a terminal multiplexer consists of three parts: 1. Managing shells and windows 2. Parsing the ECMA-35/ECMA-48 escape/control sequences 3. Rendering the shells' parsed output within their window boundaries

> Can you share some resources etc on what could a good starting point if I want to explore this as a side-project?

I'm still looking for resources myself. Check out JdeBP's comment for some good information https://news.ycombinator.com/item?id=22847168

JdeBP|5 years ago

See https://unix.stackexchange.com/a/579359/5132 for the most common architecture. It's roughly the architecture of tmux and screen. It's roughly the architecture of http://jdebp.uk./FGA/bernstein-on-ttys/sess.html , too.

I have a somewhat different, layered, architecture with finer grained components. The terminal emulators, multiplexor, input method handler, and realizers are all separate processes, and the communication among them is via (memory-mapped) regular files and FIFOs.

* http://jdebp.uk./Softwares/nosh/guide/user-virtual-terminals...

It's more rigid in the multiplexing layer, with little notion of creating and destroying inner terminals on the fly and no notion of windows or panes, because it was initially created to be a user-space workalike for the kernel virtual terminals in Linux and FreeBSD, that are derived from SCO Multiscreen. So there's just the notion of a fixed set of virtual terminals, presented one at a time, with the Alt+function-key switching and a replacement chvt command.

It's more flexible in other ways, though. The components of the system are replaceable, and don't have to be put together in this particular way. There's no reason that one couldn't write another type of emulator, handling a completely different suite of escape and control sequences, and just plug it in alongside the existing one. And there's similar flexibility in the other layers: one can (and I do) simultaneously realize the same set of multiplexed terminals onto a remote terminal over an SSH connection as well as directly onto the local machine's framebuffer and keyboard(s). It could be realized onto X11, or (if someone finally documents the undocumented Mosh protocol) a Mosh client.

Indeed, there's no reason that a more complex multiplexing layer couldn't be substituted, providing something more like the screen/tmux paradigm, with the multiplexor starting up subordinate shell and terminal-emulator processes on the fly and compositing the lower screen buffers. But I didn't set out to reinvent screen/tmux. I set out to do virtual terminals in user-space instead of the kernel, with application mode code almost none of which (apart from the stuff that grants access to the framebuffer and keyboard devices) needs or runs with superuser privileges, and where the components are isolated even from one another.

See the StackExchange answer that I hyperlinked to for more on the actual terminal emulation part.

kitotik|5 years ago

Nice work!

This is exactly what I hoped tmux was when I first tried it.

Will definitely be following this.

ralls_ebfe|5 years ago

Looks really interesting. :D