Hacker News new | ask | show | jobs
by ray__ 1504 days ago
I still don't quite understand the value of tmux, at least on a modern machine. If I need another terminal, I just pop open another terminal window and tile or tab it. If I want to keep a set of terminals organized, I use workspaces (at the OS level).

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?

7 comments

You can ssh into a system and use tmux. Then you can detach from the session and when you come back a week later your tmux session is still there and you can continue with no friction. Also i find it interesting that you said you don't see its value and then continued to explain its value. For me it's definitely more common to work with systems/servers without a DE and WM. It's just better to handle this problem at that level instead of at the terminal level because then your shell setup becomes terminal and platform agnostic. With mouse support turned on tmux feels almost like a WM in the shell, which is amazing.
I’m a huge fan of `tmux -CC` for stuff like this!
I didn't know about this. For others, it's called tmux control mode, and integrates tmux within a terminal emulator for things like split panes and tabs. It requires terminal emulator support. Here's some documentation: https://github.com/tmux/tmux/wiki/Control-Mode
Are there any Linux terminal emulators that implement this? So far the only I've encountered is macOS's iTerm 2 and it's brilliant but mac-only.
You want to be able to disconnect and reconnect to your terminal session on the fly for any of a number of reasons:

- 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.

Imagine you're at work, and you have tmux running with 15 sessions to various machines. You go home, connect to that tmux session and you can keep working without having to re-connect/SSH and log into 15 machines and just continue where you left off.

It's sort of like being able to RDP into the machine you were working on except it's text-based.

So something like abduco (https://www.brain-dump.org/projects/abduco/) should do the job too? I think GP's comment was more concerened with the terminal multiplexing, not the ability to detach a session.
abduco claims to be a tmux alternative, which there are probably a few - I don't think any of these points being made are attempting to claim tmux is the only tool with these features, only that the features are very useful - tmux just happens to be one of the most popular tools in this category of tools
I see, thanks! This sort of use case would be rare for me, but when I've needed to manage sessions I've used screen. I can see how tmux would be valuable for managing more complicated groups of sessions like you describe.
You lost me at go home and keep working...
tmux is a basically all of the modern features of terminal management but scriptable.

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.

On Vim there's a plugin called Vimux which allows me to control other pane from Vim. For example, I type `<leader>l` and it runs the last command on the next pane, which usually is a command to test the code I'm working on.

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.

You can do everything from the keyboard. No need to ever reach for the mouse. Ever. Once you master it (the learning curve is a bit steep though), you'll never want to go back. I do use my own customized key-bindings.

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.

One of the first reasons I starting using screen (switched to tmux later) for local terminal work was so I can re-open it if I accidentally closed the window. It's still one of my reasons for using it.