by ray__ · 4y ago · 0 comments
I can obviously see its value if there is no window manager or desktop environment on the system I'm using, but that's rare these days–if I'm working on a system with neither of these it's always over ssh. With a WM or DE it seems like tmux just adds a redundant layer of organization. What am I missing?
- You're connected to a remote host and you don't want an unexpected network issue to kill your session
- You want to be able to periodically check on the status of something on a remote host but don't feel like keeping the connection open all the time
- You want to connect to the same session from different clients
- You may need to restart you graphical session and don't want that to kill your terminal session
A really simple way you could get this working is what abduco and detach do: the demon just blindly shuttles input and output between the client tty and the virtual tty that the interactive process is running in. However, when you reconnect to an existing session, you get no context, because the server doesn't know what it would need to tell the client for it to reassemble the tty state.
In order for that to be possible, the daemon would need to keep track of the terminal state internally. It's really annoying that that's necessary because now your actual terminal emulator isn't directly communicating with the process it's displaying, and you won't be able to access any features of your terminal that the daemon doesn't support.
But once you already have this background process that's keeping track of terminal state, you might as well build in other features that would require that, like window management, otherwise people who want those features will end up having yet another layer of terminal. If you don't want those features, you can pretend they're not there.
It's sort of like being able to RDP into the machine you were working on except it's text-based.
So you can have tabs, splits, sessions, etc, all scriptable. Eg if I hit F1 in the shell I automatically get the command’s man page alongside the interactive shell.
I’ve also used it on occasions where I’ve needed to pair program with someone on a poor internet connection. We’d SSH into a common area and share a tmux session while chatting on a regular phone call. Thus no bandwidth heavy video conferencing.
It’s also been handy back before I worked fully remotely, I’d have a dedicated desktop running tmux and when I got home I would VPN into the office and resume the tmux session so I could resume where I left off.
Sure, you can do everything in a WM or DE, but I use Linux and macOS and it's nice to have the same configuration, keybindings and environment everywhere. I also find tmux more customizable than Gnome Terminal and easier to setup than st or urxvt.
Also - for long running processes, you can run stuff in a tmux session, go to bed, and wake up hours later and see exactly what happened. You can make the scrollback buffer as big as you want. My scrollback history is 50k lines, and that's totally fine. Of course the history is searchable with vim commands which is also nice.