Tmux is worse-is-better
hiandrewquinn.github.io
hiandrewquinn.github.io
It's nice that Kitty does most of what tmux does built in, but as the author points out, that's not really all that helpful for anyone who does any work over ssh.
And to me, bundling all that into a terminal emulator is bloat. Terminals should be terminals. If I want a multiplexer on top of that, I will... use a multiplexer on top of that.
I am potentially sympathetic to the idea that tmux and screen make it harder for terminal developers to add new features to their terminals. I don't really know enough about the issues involved to form an opinion. But from the perspective of a regular user, I do not want a multiplexer in my terminal app. When I need one, I prefer to reach for an app-agnostic multiplexer like tmux or screen.
The main problem with Tmux that no one talks about is its arcane configuration and interaction patterns. If you set up a ton of config while gritting your teeth, it begins to work well, but the configuration semantics are a nightmare. I would love something similar to tmux that has sane configuration and theming. I switched from XMonad to i3 for the same reason.
Since I keep my configs in a repo, I just checked the last time I changed my `.tmux.conf`. Turns out it was 2018, and I changed a grand total of 2 lines. And I use tmux daily, not just remote, but also on my local machine.
So yeah, if I am using something for more than half a decade without requiring any change, then its pretty safe to say that whatever hassles the configuration of that something imposes, is completely irrelevant.
It’s not only the config, though. It’s the arcane shortcuts and the weird way it seems to handle most things (trying to get the mouse working is a bloody nightmare and it regularly borks the terminal). I have a mouse with a scrolling wheel, for example. It works fine with most programs over ssh, why is it such a pain with tmux? Such pains remain even after having felt down the rabbit hole and spent 2 weeks tweaking settings.
iTerm2 is fantastic and I would be very happy to just use it and call the problem solved, but I don’t have a Mac at work.
It's literally one line of config.
> It’s the arcane shortcuts and the weird way it seems to handle most things
Tmux is a TUI and the shell and other software running on it are themselves TUI. There will be conflict and the prefix solution is actually simple. Tmux solves one particular problem and solves it well. It's on you if you want it to be something else.
All of which can be configured.
More often than I’d like! tmux config has broken backwards compatibility on me multiple times over the years.
This is fine for most software — you upgrade your config once and you’re done. However, the nature of tmux is that I use it on many servers, some old and some new, some with tmux 1.x and some with 2.x. Getting a ~/.tmux.conf from my dotfiles repo that works across both has been papercutty.
Love tmux though & can’t imagine tty life without it — I run it locally as well as on remote machines.
My home git log shows my first tmux configuration was in 2017. Since then, several options have been removed, they now throw an error on startup, and mess with muscle memory for key bindings that are essential to using a program like this.
This means that to get tmux working properly again I have to catch up on years of release notes to figure out what I'm supposed to change. I have never once had to do this with screen despite using it for over 20 years.
Any time my muscle memory is betrayed, I give up and go back to screen and don't bother touching tmux again for several months.
It’s a tmux plugin that replaces the default Ctrl-b keybindings with the same keybindings used in i3wm (including turning on automatic tiling instead of manual splitting). Given that you use i3wm on your desktop, you might like it :)
Sadly, that seems to leave me with only 2 options that work well over SSH:
- using a terminal with client-server model and built-in multiplexer (VSCode Remote SSH extension, WezTerm)
- using iTerm2 with tmux integration (apparently nothing else implements tmux control protocol https://unix.stackexchange.com/a/280829)
BTW this is the first time I've seen a working drag and drop TUI (you can use drag-and-drop to move floating panes around).
[0] https://zellij.dev/tutorials/basic-functionality/ [1] https://github.com/sponsors/imsnif
I found out about it from this blog post nearly two decades ago: http://web.archive.org/web/20190120170204/http://www.termina...
set-option -g mouse on
Drop that in your ~/.tmux.conf file.Then you can create new windows or panes by right-clicking (and clicking on the drop down), click on a pane to focus it, click on a window name to focus it, right-click to rename it, drag to highlight text or to adjust the width of a pane, etc, etc.
Both are actively maintained and can work with modern terminals, as long as the hosting terminal is standards compliant.
I don't understand why people love to break standards.
I don't agree with this. There are tons of standards (even if it's de-facto) from VTxxx to XTerm's emulation standards. If there were no standards, it wouldn't be possible to talk with a modern system using a real VT320 (Yes, we have these), or with a vintage system with a modern terminal over a TTYUSB device.
> The problem happens when someone wants to add something new to the terminal ecosystem.
I understand, but every decent standard should take what's done before them and be prepared to face with it. Let it be Ethernet, TTY, even something modern like DisplayPort. When people doesn't do their due diligence and spend the time required to handle edge cases, things are bound to break (e.g. Cheap monitors' firmware contains identical serial numbers, causing all types of shenanigans in multi-monitor setups).
> 2a) Designing something becomes harder because it has to be designed to work with the horrible hack that is terminal multiplxer.
For harder part, see the previous paragraph. i.e.: One should do their homework to work with other systems. On the oh gawd horrible hack! part, That "horrible hack" is saving hours of work per month per person who work with remote servers for ~30 years now, and nobody is planning to give them up AFAICS.
> The tty model is dead simple, one tty per child process. When you add a terminal multiplxer it completely confuses this simplicity, making it instead multiple processes per tty and does it in a way that is opaque to both the processes and the host terminal, leading to endless bug and incompatibilities.
Maybe one should draft a new standard about multiplexing terminals persistently without it being a hack? There's a big gap there, as you point out.
> 2b) Any new feature is now gatekept by the individuals in charge of the multiplexer projects.
Both screen and tmux are maintained properly, and they fix the bugs they cause actively. For example, screen was causing a problem in SGR mode, and they fixed it 2 months ago [0].
Oh, on SGR; it's an ECMA Standard. Standard-48 to be more precise [1]. So, again, there are standards, and you can build new ones, and I bet, terminal multiplexers will play along if you don't throw eggs at them.
[0]: https://git.savannah.gnu.org/cgit/screen.git/commit/?id=c184...
[1]: https://www.ecma-international.org/wp-content/uploads/ECMA-4...
I suggest you go plug a VGA cable into a DisplayPort and see what happens.
The horrible hack is saving you and the few other very loud people that use it hours of work. I for instance have been using remote servers for 40 years without ever needing a multiplexer. They have always been, and remain, horrible hacks that I rejected when I first came across them and that have been a drag on the entire terminal ecosystem for 30 years. Thankfully they are finally on their way out, thanks to a new generation of terminal emulators and are using the tty the way it was designed to be used.
The new standard is the old one. Use the tty as it was intended and designed without a horrible hack in the middle. And if you really need remote persistence via a multiplexer of all things, then use one provided by the terminal emulator you use so that it integrates natively, seamlessly and correctly with the terminal emulator. Granted currently only WezTerm provides such a multiplexer, kitty for instance instead multiplexes SSH access via SSH control masters. But its developer has indicated he will someday write a tmux replacement that is kitty native.
Oh and on SGR it is an ECMA standard, only in the breach. For example, color support as it is actually used in terminals violates the so called specification.
As for multiplxers playing along, here you go: https://github.com/tmux/tmux/issues/1391
Complete and utter drag on the ecosystem.
OK. Let's look what happened some of these opinions.
- PDF became two different ISO standards.
- USB started as a de facto charging port, became de jure in EU.
- DMX, MIDI, DE-9 RS232 connectors are all de-facto standards, but used as de-jure now.
- Tons of file formats in scientific and engineering computing is in fact de-facto standards, yet they flourish.
So, it's meaningless whether a standard is de-facto or de-jure. If it looks/walks/sounds like a duck, it's a duck.> I suggest you go plug a VGA cable into a DisplayPort and see what happens.
I use something similar to this [0]. It works.
> The horrible hack is saving you and the few other very loud people that use it hours of work.
I love how you liberally throw the h-word around. Because horrible hacks became conventions over history. Vi's latency hiding can be considered "a horrible hack", or "brilliant" depending on the perspective. Same can be said for HDMI for example. Piggybacking on DVI for video signalization, adding a couple of digital lanes for sound and Ethernet, it can be considered a horrible hack, yet it's a de-jure industry standard. IOW, someone's opinion, just in a written form with some stamps and a logo.
From my vantage point, people not using terminal multiplexers (tmux/screen) are a shrinking minority, yet from your perspective it's the opposite. Considering the oh gawd horrible terminal multiplexers are still maintained, and I still initiate people on screen or show them tmux as a screen alternative, I don't see they're going anywhere. Your perspective may differ. I'm mostly talking about younger generations, I may add.
> I for instance have been using remote servers for 40 years without ever needing a multiplexer.
I think you're lucky for not having to debug things on the go, for days, or managing servers on a responsive and stable network. I sometimes have no luxuries, so I have to use horrible, horrible hacks to get things done. It works brilliantly unfortunately. Shame on me.
> I rejected when I first came across them and that have been a drag on the entire terminal ecosystem for 30 years.
That's a long grudge to hold. I'm sure it's not the only one. Think about your health. No it's not meant to snark. I'm honest.
> Thankfully they are finally on their way out, thanks to a new generation of terminal emulators and are using the tty the way it was designed to be used.
I don't see it's happening, sorry. What I see is more hacks are piled upon hacks. Some might stick and become standards, some might die.
> Granted currently only WezTerm provides such a multiplexer...
Wezterm's multiplexer is a regular old multiplexer which connects to a remote wezterm instance. IOW, just a different transport which encapsulates a WezTerm instance. There's nothing magic here. It's moving the hack to another layer. Now there are two transports, and Wezterm's one is not interoperable with others. So it's a really horrible hack from my perspective. If something is not interoperable with other tools, then it's out for me. I can't be bothered to install Wezterm to all and every server I work with. Which is >1000.
Unfortunately, I have the luxury of choosing the terminal which I want to work with in any circumstance. As long as I can connect to my remote server, my persistent workspace is there. I don't need a local Wezterm to be able to work.
> ...without a horrible hack in the middle.
Wezterm puts the horrible hack on top. Like a cherry. Bright and eye-catching, in a bad way.
> As for multiplxers[sic] playing along, here you go: https://github.com/tmux/tmux/issues/1391
I read the bug report. I think the problem is the approach. If somebody is so adamant in a feature, and the maintainer doesn't want to add that feature, a) you can patch it yourself, b) you can fork and patch it yourself. It's free software. The tmux maintainers doesn't owe you anything. I bet, if you send in a nice patch, they won't ghost/reject you.
BTW, a mux is just another terminal emulator inside your terminal. It's not more of an hack compared to an ncurses window, or old graphic interfaces in UNIX systems.
> Oh and on SGR it is an ECMA standard, only in the breach.
Many standards are flexed. Many graphics cards do not fit inside the PCIe mechanical standard, for example, but they work.
> For example, color support as it is actually used in terminals violates the so called specification.
My terminal has fallbacks for a lot of modes. This is what backwards compatibility is for.
> Complete and utter drag on the ecosystem.
Sorry I don't see/feel it for the last 20 years.
So, in short, I agree to disagree, and genuinely wish more power to you in your endeavors. There are no hard feelings here, just tone-matching.
Hope to have a longer chat and have the opportunity to learn from each other.
Cheers!
[0]: https://media.startech.com/cms/products/gallery_large/dp2vga...
1) The difference between WezTerm's multiplexing and say tmux, is that wezterm's multiplexing supports all the same features/bugs/syntax and quirks as WezTerm itself. It does not have to translate between what it gets from an unrelated terminal implementation that it has only the most superficial information about to its own internal representation and back, which is what a multiplexer like tmux has to do. Tomorrow if Wez decides to add a new feature to WezTerm, he can add it to his multiplexer at the same time. Thus, the WezTerm multiplexer is a) much more robust than tmux b) not a drag on the entire ecosystem since nothing other than WezTerm itself depends on it implementing anything.
And therefore, unlike tmux, it is not a horrible hack.
To put it another way, tty's are sufficiently complex that multiplexing if needed at all, must be done by the terminal emulator, not an unrelated third party sitting in the middle. You say a multiplexer is another terminal inside the first, I say that is precisely the problem. It is an incompatible terminal emulator.
The protocols introduced by Kitty, like the Kitty Graphics Protocol and Kitty Keyboard Protocol, were sufficiently well-documented that other modern terminals (e.g. WezTerm) have adopted them as well. Moreover, both protocols offer advantages cf. the modifyOtherKeys and Sixel standards used by e.g. xterm.
I myself use 2 terminals: Alacritty and WezTerm. The former for local work, and the latter for my VMs, and occasional remote server work.
I couldn't explain exactly why I use separated applications, since WezTerm works well for local (which even has a menu entry for that) and remote alike, but I'm comfortable with the workflow that I have today, and for me it's enough and what matters.
If emacs wasn’t really slow with long lines in buffers and high volume output, it could be better
Interpretation of intent and “helping” the user are neither needed nor desired, and at best leave everything alone and at worst misinterpret and get in the way.
I have never copied anything out of a terminal and gotten anything other than what I copied when I pasted into sublime text, and I’ve never used iterm2.
Are you talking about copying from a terminal and pasting into OneNote or some other “more than plain text” application or something?
This is the single feature I miss the most in any other terminal emulator.
The iTerm2 feature being discussed means that selecting works the same way it does for graphical programs like Gedit or Pycharm or Word — if you select 10 lines you select 10 lines and your window size, font size and visual wrap setting don’t factor into it, and when you paste, you paste what you copied as it was. I would say this is the intuitive and reasonable behavior, but it’s one that is not simple to implement. A visual word wrap should be a purely visual thing and s back to back Cut and Paste should result in nothing changing.
Does that include all trailing whitespace in the rectangle you selected? Should your selection automatically minimize to unselect said trailing whitespace (even before copying, I mean)? Should a selection preserve tab characters or replace them with spaces? What if the selection does not start at a tab boundary, should it ignore or include the half-selected tab instance?
I don't think there is a singular answer to what "copy selection verbatim" means.
What is this? I've been using iterm2 for years and don't know about this (and can't seem to find anything mentioning it).
“Tables” is imprecise, but is one use-case: it’s more about identifying soft boundaries like the lines between tmux or vim splits and limiting the selection to one side of the split. If you have pipe-delimited tables, it lets you select a single column of values.
I just tried this in kitty and it didn’t work
IMO this setting belongs with the application, and especially with tmux and nvim supporting this natively, you don't really need the terminal itself to implement some potentially fallible heuristic. For example with iTerm if you accidentally drag outside the pane boundary, the selection immediately expands to include both the panes, which is not ideal.
Sometime in the last year, iterm2 started adding ~00~ crap around stuff I paste. then some yellow 'alert' box at the top indicating I'm doing something wrong and do I want to keep doing it. makes 0 sense to me, and... annoying because it didn't do it for the first... 6-7+ years I used it. My behaviour didn't change, but iterm2 starts breaking.
No doubt there's some 100% logical explanation as to what changed such that my standard copy/paste is 'wrong' now, but... would have preferred they'd have kept the original behaviour.
There’s a toggle in the terminal settings
Wezterm terminal supports multiplexing from the box: https://wezfurlong.org/wezterm/multiplexing.HTML
Also, there is Hyper terminal, and standalone protocol to implement multiplexing https://www.reddit.com/r/commandline/comments/q5mj11/htm_a_c...
If you know other options, please share.
I work in windows, but at home I use macos, so I stick to wezterm. I use it with single config for both platforms (config is written in Lua)
If you are hoping to new machines every time then sure.
But lets be honest, thats a minority.
I don't know kitty in specific, but wezterm ie. can connect to target via SSH, start daemon of itself there and actually work better then tmux, because it's controlled from the client (where the gui runs), but with all the tmux upsides.
And yes, it's not as portable as tmux (simply because its not as popular), but again, in majority of the situations the setup required is really not that much. Especially if you would spend that time on tmux config anyway.
The thing I like about tmux and zellij is persistence and the "task-runner" nature of them. Its great for managing sessions and running things in the background. Though I do hate how they also break a lot of features that I do like about terminals.
Kovid Goyal has a history of being incredibly opinionated to the point of being combative and toxic at times. He makes some great software, I’m a user of kitty, but this hyperbolic tone about this issue is not shocking to me at all.
https://bugs.launchpad.net/calibre/+bug/1714107
There are a lot of other gems too if you look through Calibre's bug tracker
https://bugs.launchpad.net/calibre/+bug/885027
The cynic in me thinks it's more likely that because kitty offers tmux features he wants to lock users in to his product.
But it's also foss, so, you're still right.
My God, what have we done
Yes efficiency is good. But... Damnit man! The performance numbers shown for this low power processor are 43MB/s without tmux vs 30MB/s with tmux. It's likely going to take a lot of activity for that to aggregate into even a decent fraction of a ms of latency.
Beware extremists. Some people will never be pleased, will accept nothing. The only answer is to cut cut cut forever. There's a cult of people out there that idolize performance above any practical use like a god & will destroy & savage anything else. Deny this falsity. Respect performance, but also allow other factors to balance in.
(Side note: I'd love to know how dtach performs. It has the key advantage to me of tmux, which is detachability, but no virtualization. Great for running a vim session! And by design is a very pure simple pass through.)
Also, latency is not a direct function of throughput. The two are separate. In this case the latency will come because when you have tmux in the middle it means your command line program writes to a pipe, which is a buffer in the kernel. tmux then has to read from that pipe, then it has to process that byte updating its internal state, then it has to generate the output bytes based on the internal state, those output bytes are written to another pipe, and finally the terminal reads from that second pipe.
There is a whole extra pipe with associated context switches for every byte (or more accurately every packet since reads/writes on a pipe are buffered). This will add latency for example for every keystroke no matter what the throughput numbers are. A pipe operation requires a poll on the pipe fd which is a context switch. Apart from whatever internal processing tmux does, there are four extra context switches added for every keystroke + response.
Also, why have you done an “alacritty” vs “alacritty+tmux” benchmark yet have not done a “kitty+tmux” benchmark on this same table? That’s a big omission. The entire conversation is about the effects of adding a multiplexer on top of a terminal.
I chose the ASCII column because it's 99.999999% of what 99.9999% of developers see.
I think it's an unavoidable cost for any remote re-attachable system. No matter it's tmux/vnc/whatever remote protocol. But even in all these options. Tmux is still the lightest weight among them. Which can runs on a 500mb-memory vm totally fine. Spin up a actual desktop is way way more heavier than a terminal emulator like tmux. And allow you to split the terminal is just a free bonus tmux provided.
In an ideal world, connection can live forever, so re-attachable protocols like those are totally unnecessary. But in reality, the network sucks often.
This is the real reason I actually need tmux. I often lose connection to a server for various reasons and don't want to lose my vim session or whatever
stealth is basically impossible with TCP
I have moved between tmux, byobu, and screen at various times in my career. I wouldn’t say one is better than the other, as they all do the job I need just fine (eg persistent session state on remote machines)
But I have a window manager, so all I ever want out of something like screen or tmux is a persistent remote session that survives network issues or me closing my laptop for a bit. Is that something that Zellij is better at?
Just try it and see if you like it. I've found that most of things I didn't like, mainly the default TUI borders and buttons, were far more easily reconfigured compared to tmux.
It is the best of both worlds. And, yes, of course it works with a remote ssh session.
GNU screen allows for redefining (at least) its hotkey. If tmux allows the same maybe you could redo the bindings more to your liking?
I love tmux and hate the default hotkey
Isn't the default command key ctrl-A for screen? Which is why I've always had to change it (to ctrl-O which is much more sensible) because I can't live without ctrl-A in the terminal etc.
If you also want multiple terminals and screen splits and etc. it's designed to work with dvtm (by the same author) which provides that side of things.
Personally I tend to have a 2x2 grid of xterms on my local machine and four ssh connections to matching dtach sessions named project-{tl,tr,bl,br} but I suspect most people who aren't me would be happier with dvtm.
If my work is unfinished, I leave the screen as is, and disconnect. We don't touch each others' screen instances on servers, so it's a safe workspace which I can return whenever I want.
I imagine everybody uses screen and tmux mainly for remote persistence.
This is a need kitty+screen doesn't answer. If I close kitty & reopen it, i'll have to re-split every individual pane, and reconnect each of them and reattach them to the right persistent screen pts...
Infact if there was a way to handle that "workspace-persistence" with terminal emulator-based workspaces, I'd ditch tmux in a minute
EDIT: now that i think about it, this could maybe be achieved by keeping the terminal multiplexer's "server", but having the terminal emulator act as a client to it
This is exactly what iTerm2 tmux integration does. Tmux exposes a "raw" control mode by starting it with the -C flag. iTerm2 uses this to convert tmux windows into native tabs/windows, complete with workspace persistence.
AFAIK, iTerm2 is the only terminal emulator to integrate with -C controle mode, which is probably the main thing that keeps me on macOS over Linux.
>> [T]erminal multiplexers are a bad idea, do not use them, if at all possible. kitty contains features that do all of what tmux does, but better, with the exception of remote persistence.
Bit funny, most of the time I’m running tmux in kitty (or ssh in kitty to a server with tmux).
Remote persistence is a pretty massive deal, though.
In general, I don’t like getting attached to a terminal emulator, and mostly just try to avoid using any unique features they’ve got. If a terminal emulator and a command line program are competing for doing a task, the terminal emulator in some sense has an unfairly high hurdle to pass: if I become dependent on the terminal emulator to do it, then I can’t replace the terminal emulator without also getting a new muscle memory for that task, if I ever want to switch terminal emulators.
Which means it has to do that task so much better than the command line program that the delta is worth more than any possible improvements from switching terminal emulators. Kitty is a great terminal emulator but this is an absurd and basically unfair bar that it could never pass.
In this case, though, it is actually worse than tmux because it can’t offer the best thing terminal multiplexers do: remote persistence, which is the killer feature.
https://github.com/kovidgoyal/kitty/issues/2511#issuecomment...
"Terminal multiplexers are a bad idea" sounds just like Sixel being "an inferior graphics protocol", and Sixel is probably another example of "worse is better".
The person working on the patch decided that they didn’t think the sixel library (which they were the maintainer of, so they presumably had a well informed opinion) was up to the task.
The description of sixels as inferior also came from the person working on the patch.
I don't use kitty myself, but many people who do seem to love it. I've come around to feel that this is truly a maintainer's judgment call. After all, they are almost always stuck maintaining the code no matter who wrote it initially, and they know better than anyone else what code they're personally comfortable maintaining.
More generally, if you like a piece of software enough, you're implicitly trusting the maintainers' judgment. You're certainly not reviewing every single line of code they write to see if you agree with it. If they betray your trust enough then you move on, but if you keep using the program then the maintainers' judgment was right enough.
The miserable survival rate of hostile forks also demonstrates that even if people care enough to fork over one issue, they rarely care enough to maintain the overall project long-term, despite implicitly asking the original maintainers to do the exact same thing.
You can add this to the enormous pile of open source forks that didn't survive long enough to have any real value to the industry.
I respect that Goyal has been bitten by this dynamic before and said this back in April 2020:
> That said, I wont refuse a patch to implement it on top of the existing graphics support, provided I was reasonabl confident the person implementing it would stick around to maintain it as well.
Especially in startups, where you can't afford to be sitting atop massive too-big-to-fail enterprise bureaucracy, and need to understand the systems, and work creatively and efficiently with them.
https://github.com/tmux-plugins/list
As a neovim user I can also very much recommend this vim plugin to seamlessly navigate between tmux panes and neovim windows:
Tmux panes and windows behave more like separate shells. It's similar to what we get with individual shell gui windows that are neatly stacked and makes it easy to follow.
I don't know if there is an equivalent in screen, but I like and heavily use the zoom feature which can temporarily minimize other splits and focus on single shell.
I didn't want to before, but now in the current year I switched from gnu screen to tmux, keeping the key bindings the same. Ending a 15 year or so streak.
The reason is that tmux supports more modern features like hyperlinks and truecolor, in the distro versions. Once settled, I don't notice a difference.
My virtual terminal (iTerm2, Alacritty) makes mouse-clicking a link opens it in Firefox.
I've used GNU screen for 25 years. I gave tmux a try 10-15 years ago, but I didn't see the upside.
I'm curious about Zellij and its wasm plugins, but equally skeptical.
All I ever do in screen is ^A D, ^A C, ^A SPC, not sure what else I need?
Programs such as GNU coreutils ls (ls --hyperlink=always) can use hyperlink escapes in the outputs to make every file name it lists clickable, for example.
Of course there are ways to escape these escapes and get them to pass through screen - I wrote an escape code script myself to do it - but that experience is still inferior to native support, which tmux has nowadays.
Well I used GNU screen for a long time but it finally broke through now due to truecolor, and I managed to switch :)
I tested both zellij and tmux before switching, I was considering zellij as the first alternative. But zellij had some noticeable performance problems compared to tmux when it comes to throughput of terminal output, so I picked tmux.
Here is mine : https://pastebin.com/ZVWYcpyU , but a lot of GNU Screen muscle memory fails for various reasons.
The main reasons I'm trying to switch are: better scrollback support, and better mouse support (both for tmux itself and for pass-through to terminal applications). Having used GNU Screen for 32 years, it's difficult for me to even think about what keys I'm hitting, it's below the level of conscious recognition at this point.
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key a send-prefix
bind-key C-n next-window
bind-key C-p previous-window
unbind C-a
bind C-a last-window
unbind A
# Default C-a ,
bind A command-prompt -I "#W" "rename-window '%%'"
unbind k
bind k confirm-before "kill-window"
bind Escape copy-mode
# start counting from 1
set -g base-index 1
setw -g pane-base-index 1
# vi keys scrollback
setw -g mode-keys vi
# Style
set -g status-bg black
set -g status-fg white
# Make current tab visible
setw -g window-status-current-format "#[reverse]*#I:#W*"Thank heavens there's someone else - I thought I was the only one[1].
[1] I use screen, and then use vim with multiple splits and tabs, with each buffer being a `:terminal`. Works very for me, because I get all the terminals I want, splitted and tabbed in any fashion I want, using my existing vim muscle memory to switch between them, minimise, maximise, etc. Also, takes about 1s to save the session if I ever feel the need to exit vim (I never do, though).
The big advantage of using a single Vim instance for everything is having all my registers shared.
I can copy something into register 'a' from file One.txt, and then paste 'a' into file Twenty.txt. Same with recording macros, command history, etc.
If any of those buffers are terminals, then I can use them just like a read-only file: copy from them into registers, run macros within them, etc.
The advantage, to me, of using Vim over Tmux, is that that I don't need to remember an additional set of key chords for moving between splits and tabs, and for resizing splits, etc. Using tmux requires additional commands and key chords to memorise.
I used to love tmux before vim had `:terminal`, but since Vim got `:terminal` there's nothing I get from tmux that I don't get in a simpler and easier way from Vim.
If I'm expecting a lot of copying between files, that's when I will break my own rule and temporarily use a split window inside vim.
Host *
ControlMaster auto
ControlPath ~/.ssh/control/%C.sock
ControlPersist 300s
And SSH will multiplex as many sessions as you want into a single connection. If you're not using tmux to allow you to resume detached session, this works really nicely. I have fingerprint auth for the first session, to establish the connection, then I can connect and disconnect to my heart's content without authenticating again unless I have no connections open for 300s.I typically use plain SSH with persistent sessions, and connect over Tailscale so even if I go offline and reappear on a different IP address my session will probably survive. If my session doesn't survive, it's easy enough to start a new one :).
The missing piece, from what others have commented about, is long-running commands. If I'm upgrading Debian over SSH then I will do that in `screen`, but for pretty much anything else I'd prefer to launch it as a (possibly ad-hoc) service and let my service manager look after it.
I actually think that value add for SSH is that people is the ability to allow long-running jobs to survive a disconnection. It can be frustrating doing something that takes multiple hours (like a large wget download) just to have your connection break about ten minutes before it's done. Even if you never use any of the other features you immediately benefit from that.
It's close to a "remote desktop" where you connect to an existing "screen" and continue where you left off, vs each time you connect, a brand new "screen" being created, and it getting destroyed as soon as you disconnect. The fact that the shell dies as soon as you disconnect is far more problematic than just long running jobs.
If you just bg it, it will still die when your session disconnects
http://github.com/nelhage/reptyr
Host t-sdf
HostName sdf.org
User idatum
RemoteCommand tmux new -A -s mylaptop
RequestTTY yes
Then log in with ssh t-sdf
and tmux is happily running a session named "mylaptop". Connecting again gets you back to the same tmux session.I use tmux daily and I haven't found a reason to switch.
The author of Kitty is also right about performance. I've never looked into exactly where the problem is, but tmux <- ssh <- windows terminal is very very very slow. This is most annoying when some program starts printing a ton of stuff and your control C keypress is ignored for a good 15 seconds. While this Should Not Be, I can live with it for the other gains. I do a lot of pair programming with people, and I've never seen a better or more productive setup than this one.
a) 2 separate machines
b) To get banned for running the games in a Windows VM
Work is a Microsoft place, but honestly the web version of Outlook works great under Linux. Teams is usable. (My Linux friends complain that it sucks, but what they don't know is that it also sucks on Windows!)
The program that I have the most trouble with is jlog (https://github.com/jrockway/json-logs). I wrote it so this could very easily be my fault. (I think it's the colors and whatnot, which I have not explored yet.)
In like 2008 I was using a Perl library that was all about zero-copy networking. That is not what this is.
The ~ (tilde) codes in OpenSSH imply that it also performs minimal parsing. Particularly, "(return)~." to terminate a locked session.
The tmux program is invaluable to me when I have a long-running set of interactive commands, and I want them to survive a network disconnect.
There may be valid criticisms of tmux, but wow is it good at this particular thing.
Users will gravitate towards what makes their life simpler, once it was screen and now it's tmux. Regardless of the technicality behind it.
I actually gave zellij a try recently but went right back to tmux. Zellij seems like a very promising software but tmux still has a lower threshold of entry.
But with tmux the docs and ui were just so intuitive that I was a power user within weeks.
I’ve been using screen at first remotely for those cases, but eventually bailed out and used my graphical multiplexer locally instead of tmux, or not using tmux remotely when already using it locally.
If it gets too annoying, the remote session is openend in a new terminal tab and I temporarily remap the escape key to ^a on remote tmux.
(I don't use iTerm2's native tmux integration, so any poor interactions with that when I'm on Mac aren't a concern, and when I'm on Linux gnome-terminal has just as much utility for me.)
Try it out -- your tmux muscle memory (e.g. all the hotkeys you remember) will also work out of the box.
I went from tmux + vim TO (doom) emacs + tramp + projectile. I think I outgrew vim, and emacs EVIL gave me VIM but also magit and org and projectile. I tried to work in the emacs shell for a while. I realised I need tmux persistence still. Emacs shell also just doesn't do well with EVIL mode. So now I just do all development on emacs and manage runs etc through my tmux, occasionally still using vim on the tmux to manage config files when I don't want to load them into emacs because its a one off.
I dk about kitty, but I'm a fan of Kovid Goyal's calibre. I can't imagine how I would live without a. multiplexing b.persistence c.returning me to my context. And I never have had any tmux problems.
Tmux undoes all the fancy performance end ergonomic stuff they spent their time and energy developing. Moving stuff to the GPU, multithreading, etc. -- all just to call tmux anyway and lose 100% of those features!
What we really need is a protocol for tmux (or other terminal multiplexers) to expose its internal state to native terminal emulators so that you can get the best of both worlds. That's a tremendous amount of work, though.
https://iterm2.com/documentation-tmux-integration.html
https://github.com/tmux/tmux/wiki/Control-Mode
The downside is it doesn't work very well. Tmux tabs open as new iTerm windows instead of tabs, there are resizing bugs, etc.
So... like how a terminal emulator translates escape codes, modifying them in hackish ways to get them to work with X's/Wayland's/users' concepts of windows/sessions? :)
Obviously that's not an apples to apples comparison but really, while that may make it more complex and slightly buggier I don't see how that makes it bad.
> I find myself typing out “tmux” as the first command I run. Because it’s always going to be there, and it does the one thing I actually need it to no matter what: Let me run multiple shells at once, without SSHing in multiple times
I don't understand why people hate opening up another SSH session. If you're really worried about the 10 seconds it might take, you can easily configure it to take more like 1:
-M Places the ssh client into “master” mode for connection shar‐
ing. Multiple -M options places ssh into “master” mode but
with confirmation required using ssh-askpass(1) before each op‐
eration that changes the multiplexing state (e.g. opening a new
session). Refer to the description of ControlMaster in
ssh_config(5) for details.
The only reason I ever use screen is for persistence, the multi-windows is just a secondary feature.(Since when is tmux "always going to be there"?)
Well, for one example, when you have an SSH key with a passphrase, you need to enter the passphrase at the start of every new SSH connection. If you are working with multiple servers continuously and lose your SSH sessions when your PC goes to sleep, it's quite nice to have tmux.
- name: Install custom tmux configuration
become: yes
become_user: ubuntu
git:
repo: https://github.com/gpakosz/.tmux.git
dest: /home/ubuntu/.tmux/
- name: Set up custom tmux configuration
become: yes
become_user: ubuntu
shell: |
cd /home/ubuntu/
ln -s -f .tmux/.tmux.conf
cp .tmux/.tmux.conf.local .
- name: Set up further tmux customizations
become: yes
become_user: ubuntu
blockinfile:
path: "/home/ubuntu/.tmux.conf.local"
insertafter: "# EOF"
block: |
set-option -g default-shell $SHELL
set -g mouse on
set-option -g history-limit 25000
set -g @plugin 'tmux-plugins/tmux-resurrect'First impression: way too much visual clutter. Second, way too many key bindings I don't need. And one configuration file later: a perfect replacement for tmux, with just the right amount of features for me.
This sounds like the author seems to ignore the ground reality. For the vast majority of users, tmux simply does its job and gets out of the way. They (we) don't even notice these subtle issues. It's simply a non-issue.
Stuffing the entire multiplexer into a new terminal emulator sounds like a solution in search of a (specialized) problem. Not just that, you now have two problems: first, you have to learn the new terminal emulator; then, get to the built-in multiplexer with its own quirks.
The classic cliché of "do one thing and do it well" applies here.
I think I‘ve been walking this path for twenty years now.
I'm confused. Couldn't you just open a new tab to do this? Or just alias your shhing to a 4 stroke alias like "sshg"?
What a weird way to describe it. It sounds more like an alternative to gnu screen [1] to me. Comparing either of those to i3 seems like a category error to me.
---
Tmux is great because its features work out of the box without a need to customize anything, this is a common trait of a useful and popular software (bash, ssh, coreutils, curl). i3 is not even close to this.
But I end up using the native terminal a lot more. I love smooth scrolling, command key shortcuts and, for whatever reason, colors are a bit off when I log into Debian. These tiny details add up.
Vim even has a built in terminal these days, so it’s one less reason.
But it’s a nice utility to have in your belt for sure.
And I'm not even ashamed
tmux attach >>>> kitty
That's it. Even with mosh it's useful. On latency witth escape codes and issues with vim/vis,
set this at ~/.tmux.conf: set -g escape-time 10To be unambiguous, that's not the "worse is better" I'm talking about. That's straightforwardly better is better.
Its UX - like scrolling, copy pasting, pane management, etc - complements other terminal apps, resulting in a workflow that I find consistent and unobtrusive.
Kitty developer should really ponder on why people use terminal multiplexers in the first place.
I do and here is the thing: i can live happily without kitty, but i can’t live without screen (or tmux).
Quite frankly i do use mac os built in terminal and it’s fine? I do everything in a screen session anyway.
If i want a better terminal emulator i have SecureCRT.
Screen was not good, because Control-A is important in both Emacs and Bash.
I thought everyone mapped it to ctrl-a
Then I have mapped | and - to split screen horizontally and vertically
Sometimes if I see an advantage that's both big and obvious, I'll take the plunge and remap. Like as a teenager when I realized switching to Bumper Jumper in Halo 3 would make me much better with aerials, because I could turn and jump simultaneously. Otherwise the annoyance of having to relearn the command bindings any time I'm not at one of my preferred interfaces just doesn't feel worth it.
That being said, I did recently get one of those fancy split keyboards which lets you remap the keys. Ctrl is something I trigger with my thumb now, not pinky, and so C-b feels as natural as C-a would at a normal laptop keyboard.
echo "/path/to/long_process.sh" | at now + 1 minute
I use kitty and the kitten ssh [1] to login easily to remote hosts, and automatically setup the environment.
I can use a simple bash like
#!/bin/bash
kitty @ launch --type=tab --title='Server 1' bash -c "command1; exec bash"
kitty @ launch --type=tab --title='Server 2' bash -c "command2; exec bash"
kitty @ launch --type=tab --title='Server 3' bash -c "command3; exec bash"
If I need several servers at once. Could be done with other shells too.I can run loooong processes on the host with a simple bash script and the marvelous `àt` [2] command that nobody seems to know any more like:
echo "/path/to/long_process.sh" | at now + 1 minute
And the team can reuse those simple bash scripts!If `at` is not installed, and you need to run multiple looong tasks, try `nohup` [3]. Another lost command full of great functions like:
nohup command1 &
nohup command2 &
nohup command3 &
If you and your team is happy with tmux, that's fine! But doing more or less the same things with easy linux commands is – in my opinion – the better way.[1]: https://sw.kovidgoyal.net/kitty/kittens/ssh/
[2]: https://linuxhandbook.com/at-command/
[3]: https://www.howtogeek.com/804823/nohup-command-linux/ and https://stackoverflow.com/questions/5164985/how-can-i-use-no...
Edit: Formatting
echo "/path/to/long_process.sh" | at now + 1 minute
And it adds the benefit to simply call that script again, if you need the same long process again.
Even a 386 running at 20 Mhz can trivially handle Tmux what's this whole "oh it has to parse keystrokes twice" malarkey?
I get that software bloat is a problem, but it's a little strange to hear a man whine about the overhead of a byte getting parsed twice as part of a terminal session when ten years ago desktop computers had around 8-9GB/sec memory bandwidth and single-thread performance measured in multiple billions of operations per second...
...when he refuses to split out highly dynamic functions (the news parsers) of Calibre into a plugin so that he doesn't have to version-bump Calibre every time a newspaper slightly changes their website and breaks the parser, forcing tens of thousands of users to update the entire package (and he doesn't implement a self-updater, much less one with binary diff capability.)
tl;dr: tmux has saved my work many times, and Kitty affordances do not make up for that. And it's an integral part of my dev environment: https://gavinhoward.com/2020/12/my-development-environment-a... .
As an update, I'm on Alacritty.
but occasionally i get curious, so lets try this:
1: ugh, the theme is dark. gnome-terminal also starts with a dark theme. i go into settings to change that. there doesn't seem to be a settings gui so let's look at the documentation. no mention of switching themes there. a search online reveals that i need to run "kitten themes". there are tons. the day theme looks good to start with.
2: font is to small. ctrl-shift-+ helps. i don't frequently open new terminals so this is good enough for now.
3: attach my already running tmux session. (sorry but i use tmux for the one thing that kitty doesn't support: persistence). works. no problem there.
4: next up: connect to a distrobox container where i do dev work. no support for xterm-kitty terminal type. reset $TERM to xterm-256color, phew. now it works.
5: open new tabs. manpage has a nice table of the necessary shortcuts. i like ctrl-tab because i can do it with one hand.
6: let's look at my email (sup-mua runs in a terminal). oh there is a problem with the colors. the status bar is hard to read. let's try another theme. adawaita shows the list white on white? huh? ok, CLRS seems reasonable. github theme looked better, but the fish terminal colors were to bright, especially the git commands. ironic.
7: faded tabs look ugly. tab_bar_style powerline looks better.
i think that's it for now. hopefully i don't have to spend more time with configuration. i am not really a fan of having to fiddle around to much to get things working.
Yeah I know. Crazy. Mad. Foolish. but its worked for years. Of course only two sites though, I swear.
This thread has given me some ideas to toy around with and maybe add to https://andrew-quinn.me/cli/ , let's say. That feels so wrong... but oh, so right. Who needs systemd when you've got a Pi and tmux?
In Gabriel's opinion, Unix proved to follow the more adaptive design strategy in certain ways (in spite of his involvement with and admiration for Lisp), and the phrase "Worse is better" is meant to capture the essence of that advantageous strategy (as outlined in the essay).
The essay is worth reading and is a bit more elaborate than just saying "less is more", or "keep it simple, stupid".
yes, this is a much better explanation than the wikipedia
> It refers to the argument that software quality does not necessarily increase with functionality: that there is a point where less functionality ("worse") is a preferable option ("better") in terms of practicality and usability.
Besides, "less is better" is not a paradox.
There is another famous phrase that is "less is more". But it's a very different one (And "less" would clearly map into "not worse".)