One of the FreeBSD fans in my company stumbled upon a GNU screen alternative, that he insists renders it defunct.  Since my muscle memory will never allow a “smooth” transition to another multiplexer, I decided to make my first post an attempt to get myself (and others) introduced to this new stallion of multiplexer goodness.


 

Improvements over screen

You can grab a copy of the source code here, but before you do, check with your package manager of choice.  Macports, Debian (and Ubuntu flavors), OpenSUSE, etc., all have native versions for your enjoyment–most likely under the obvious package name, tmux.

Both screen and tmux provide multiple buffers, the ability to detach/reattach sessions, locking, etc..  Where tmux really shines is the ability to split itself vertically and horizontally–something the screen team has lagged behind on implementing themselves.  Fans of windows managers, however, will really appreciate the master/stacking approach to screens, allowing you to have a selection of stacked terminal windows on the side, with a primary work window in the center.

Getting Started

Its important that we learn the terminology in tmux, most importantly servers, clients, sessions, windows, panes, and pseudo-terminals.  It breaks down like so:

  • The single server manages all sessions.
  • Sessions contains one or more windows.
  • Windows are a collection of panes.
  • Panes are simply ways of laying out pseudo terminals.
  • Clients allow the user to connect to a session.

So the hierarchy isn’t hard to follow–in fact, I personally find it very easy to grasp due to the nature of the terms (i.e., window panes).  So lets gets this party started!

First and foremost, start up your client, tmux.  Since we haven’t configured or run this at all, the client would start-up, start a server, and create a session with a single window in it.  This can be accomplished by simply typing `tmux’ in the command prompt.  Before you start mashing C-a (the default screen command key), here’s one of the quirks–in tmux, the default command key is C-b, a choice I found to be extremely awkward on the fingers.  And, there’s the muscle memory.  Fortunately, the tmux FAQ shows us how to set it to whatever we want; simply type C-b : from within tmux following in the terminal to disable C-b and use C-a (or a key of your choosing):

set -g prefix C-a
unbind C-b
bind C-a send-prefix

From here on, assume that all bolded commands listed are preceded by the command key you set above.

Common Tasks

One of the most helpful things I’ve found about tmux is the ability to show the list of keybindings from anywhere, using ?.

There are a few common keybindings you’ll want to keep in mind.  First, lets look at the ones with similar functions in GNU screen:

ActionGNU Screentmux
Create new windowcc
Split window (horizontal)S"
Rename windowA,
Detachdd
Kill windowk, K&
Make window fullscreenQ!
Access program command prompt::

Layouts!

With tmux, you can take a single window (literally, one pane) and split it into several panes, forming a rudimentary layout.  Lets start by splitting the screen vertically by pressing % a few times, which should give us several panes.  Now, we can cycle through the predefined layouts by using Space.  Once we have a layout selected, lets learn how to navigate within it.

  • q displays the open panes in your current window
  • Up/o selects the next pane, counter-clockwise
  • Down selects the Next/Previous pane
  • C-o rotates the panes counter-clockwise

Conclusion

That’s all there is to it!  90% of tmux is learning to mentally unbind the screen shortcuts, and rebind them to tmux–which pays off.  I hope this has given GNU Linux users a new alternative to screen–or at the very least, a new toy to play around with.  Feel free to ask questions!

  One Response to “tmux: a screen alternative”

  1. great intro, thanks!

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

 
© 2012 Andrew McFague Suffusion theme by Sayontan Sinha