Tmux vs Screen

Here are some reasons why I recommend Tmux over Screen. Some are personal preference, some are not. If you’re a screen user, I recommend giving Tmux a try and making up your own mind (I have another post on how to setup Tmux, it won’t take long!).

  • The status bar is much easier to configure & use. Tmux allows you to easily script different status bars for the current window, windows with activity, etc. You can set the left, center, and right status bars separately, and you can use a shell command that gets run at a configurable interval to set the status bar.
  • Any command you can run from inside tmux can be run from outside using the tmux shell command, making tmux highly scriptable and allowing very complex commands
  • Much more accurate automatic window renaming. While screen sets the title based on the first word of the command, and requires shell configuration to do even that in a shell window, tmuxkeeps track of what processes are actually running in each window, and updates the title accordingly. This way you get dynamic renaming with any shell and zero configuration. For example: Let’s say you’re running Z Shell; the window’s name would be “zsh”. Now let’s say you want to edit some configuration file, so you type sudo emacs /etc/somefile. While sudo is asking for your password, the window’s name will be “sudo”, but once you’ve done that and sudo launches emacs, the title will be “emacs”. When you’re all done and you exit emacs, the title will change back to “zsh”. This is pretty useful for keeping track of windows, and it can also be especially useful in specific situations, like if you have some long-running process in another window that occasionally prompts you for input using dialog; the window name would change to “dialog” when that happened, so you would know you had to switch to that window and do something.
  • Far nicer session handling. You can do a lot more with sessions within tmux itself. You can easily switch, rename, etc. and you can move and share windows between sessions. It also has a different model, where each user has a server which controls his/her sessions and which the client connects to. The downside of this is that if the server crashes, you lose everything; I’ve never had the server crash on me, though.
  • Tmux is actively developed and is on GitHub, making it easier to contribute to (some may argue that screen is more mature, and doesn’t need to be actively developed, but I call BS, things change and I want my software to be ready to embrace that change)
  • Can do horizontal and vertical pane splits (I’ve heard screen cannot do vertical splits without a patch)

On the cons side:

  • Tmux does make it harder to copy & paste text then if you’d use a vanilla terminal (hopefully they fix that soon, it only broke in 2.1)
  • Resizing a pane with a lot of text can be very slow as tmux tries to reflow/rewrap all of the text
  • Developer has refused to add the ability to change certain default behaviors because he likes the behavior (maybe someone else will do a pull request though)
  • Not as mature & stable as screen
  • Some distros (e.g. CentOS 5) have trouble with Tmux, and I’ve been forced to overwrite TERM a few times to make things work (or copy up the appropriate term definition files)

So there you have it. If you’re still not sure, try both and make up your own mind!

4 Replies to “Tmux vs Screen”

  1. “Developer has refused to add the ability to change certain default behaviors because he likes the behavior”
    Could you elaborate on that? Which behaviours?

  2. Seems like tmux more powerfull but its easier screen to use it, imho 🙂

  3. I have not tried tmux but I am a long time screen user. The reasons you list are not really reasons to choose tmux over screen.
    1) The status bar needs to be configured one time and screen can also set the left center and right separately. Not sure on the script but I think screen can do that too.
    2) Not sure why you would want to script commands to run under tmux… Isn’t that what bash scripting is for?
    3) Much more accurate and automatic window naming. I have been in the habit of naming my windows manually (“Ctrl-a A” in screen) for a long time. This has the added benefit of not changing on me for reasons outside my control. I can see why the reasons you mentioned are cool (terminal waiting for input for example), but I could equally argue that is the opposite of what I want. I want to name a terminal something that has nothing to do with the current process and I don’t want it to change.
    4) Flexible session handling. I’m not sure this is an advantage of tmux either. I can very easily switch and rename sessions in screen. Screen also supports multi-user sessions and permissions where you can grant other access to your session and you can share the same session at the same time. I do no know if tmux can do this with the one-user-per-server model.
    5) Active development is nice, but the developers of tmux could have started by cleaning up the “unreadable” screen code and started with a complete feature set that has been tested in production for a long time.
    6) Horizontal and vertical splits. I’ve never used this feature of screen. Generally when I want to do this I do it from within vim (for diff’s and other comparison operations). Vim has the benefit of allowing me to sync the scroll on the windows to make it easy to compare.

    On the Cons..
    1) Screen has built in copy paste (“Ctrl-a [” == start copy mode, spacebar terminates, “Ctrl-a ]” pastes.

    For me the biggest con of screen has got to me the handling of changing environment variables on reattach. For instance when you log into your local machine and start up a ssh-agent, then use screen. Using that screen session to ssh into another machine and reattach to an existing screen session there does not automatically fix up the ssh-agent forwarding. It is a pain to get done if you have many nested screen sessions across a large environment. There are ways to fix it but they are not built into screen and as I understand it tmux has this by default now.

  4. I am a Tmux user. However, a HUGE advantage to screen is that it’s coming out of the box on a lot of distros (or at least AMIs and images).

Leave a Reply to Amit Cancel reply