tmux vs. screen

发布时间:2026-02-11 12:02

使用开发工具:VS Code或Sublime Text #生活知识# #编程教程#

I've been a heavy user of Screen for a long time, but I use a version that I modified back in 2002. Mostly because I wanted to be able to have the window "next/prev" navigational ordering match the order in which new windows were created, similar to a tiling window manager like i3 or Ion. The standard Screen behavior is for 'next' and 'prev' to go by window number, so that usually a 'new' window (grabbing the smallest available number) will be located elsewhere than the 'next' window - confusing if you don't remember the numbers. My preferred behavior has since been implemented in Tmux as a flag to the new-window command in 2010, and the renumber-windows option in 2012. My Screen patch, which I tried to make as acceptable as possible, including documentation additions and so forth, did not generate any discussion on the Screen list in July 2002 (then "[email protected]", can't find archives). In fact it was not even acknowledged, even when I sent it again a year later.

Since 2002, I "rebased" my patch a couple of times to apply to newer versions of Screen. However, when I got to version 4.3 (2015) I noticed an undocumented change which broke one of my uses of screen - namely that 'stuff' now interpolates environment variables. I didn't need that feature, and I couldn't figure out how to easily escape the argument to 'stuff' (so that I could send text containing dollar signs) so I just kept using version 4.0 (from 2004).

I use Screen's 'stuff' ('send-keys' in Tmux) in an Emacs function which sends the contents of the current Emacs region to a specific window number. That way when I am writing code in a scripting language, I open an interpreter, I give the intepreter window a special number, and then I can send lines of code from my editor window directly to the interpreter window using this Emacs binding. It's hacky but I like it better than the pure-Emacs solution, since I can also interact with the interpreter in its Screen window using standard keystrokes. It's a bit like a GUI IDE, but I don't have to use the mouse or stare at a blinking cursor.

Another feature I implemented in my patch is the ability to "mark" a window, and then to reposition the marked window to be "next" after the current one. For me this is a much more natural way of reordering windows than renumbering; it is like the copy/paste paradigm, or "drag-and-drop". (I recently figured out how to do this in i3 as well.)

It should be possible to do the same thing in Tmux, for example as of 2015 there is a facility for "marking" a pane. Or perhaps a more elementary solution could be worked out with stateful shell scripts. I implemented a short script and keybindings to try the "marked pane" method, and it worked a few times but then Tmux crashed with "[lost server]". Then I found Tmux crashing even without my trying to do anything complicated. Apparently it has been crashing for some users for a few years at least. Sometimes the server crashes, sometimes it starts using 100% of the CPU and becomes unresponsive. I've never seen Screen do either of these.

In theory, Tmux is superior to Screen in several ways. It has much better scriptability, meaning that you can do things like query the list of windows in the current session from the command line, which is impossible with Screen. For example in 2015 Screen added a command to "sort windows by title". I'm not sure when such a specialized command would be useful, but this and more practical variations (e.g. sort windows by CPU usage) could relatively easily be done from a shell script in Tmux. To me it would seem difficult to do anything so creative in Screen, at least without modifying the C code.

As other posters mentioned, Tmux has a single-server model which I see as the primary drawback, particularly when the server is crashing. It is possible to work around this by specifying a separate socket for each "session". Still I prefer Screen's one-server-per-session default, which seems slightly more elegant.

Working with the Screen code, back in 2002, was educational and enjoyable for me. Oddly enough, for all its additional features, Tmux has about 25% fewer lines of code than Screen (30k vs 40k). I noticed that Tmux uses many tree and list data structures, which were slightly difficult for me to understand. Screen seemed to prefer arrays.

As I understand it, because the Unix terminal interface is so stable, there is little need for the Screen or Tmux code to adapt to changes in the underlying operating system. These programs do not really have security updates like web browsers or web servers or even the shell. I haven't noticed any problems running my custom version of Screen, last updated in 2004 (except for needing to add some configuration files to prevent Systemd from deleting the socket; these files are typically part of the distribution package anyway). Perhaps I could just work around the problems I encountered in Tmux by running a Tmux version from before it started crashing. Of course, if enough users do this then it won't be very good for new users, since it means that fewer experts will be looking for bugs in the latest official versions of these programs. However, it's hard to motivate myself to switch to a product which is unstable for me (latest Tmux) or which lacks certain features that I want (standard Screen).

I know this doesn't provide an easy answer to the OP's question, but I hope that my perspective was useful.

网址:tmux vs. screen https://c.klqsh.com/news/view/337894

相关内容

tmux vs. screen
Restore tmux session after reboot
How do I reorder tmux windows?
How to close a tmux session
DSLR vs. Mirrorless Cameras
Mirrorless vs DSLR Cameras: How to Choose
如何使用 Print Screen 键在 Windows 中进行屏幕截图
VS Code
Affect vs. Effect – What’s the Difference?
Affect vs Effect Explained with Uses and Examples

随便看看