jump to navigation

tmux the terminal multiplexer on Linux February 19, 2011

Posted by Tournas Dimitrios in Linux.
trackback

I have recently discovered tmux, a replacement for the slightly aging gnu screen (read my earlier article about the screen utility) . tmux the so called “terminal multiplexer” allows to open several terminals inside the same terminal window. Much like gnu screen, you can split the screen, re-size the different parts etc. However, tmux allow the usage of 256 color terminals and is based upon a client server infrastructure. And before you ask, like screen, it will stay alive and run your favorite  app (even if you close the terminal ) until you reconnect to the session .

tmux uses a client-server model. The server holds multiple sessions and each window is a independent entity which may be freely linked to multiple sessions, moved between sessions and otherwise manipulated. Each session may be attached to (display and accept keyboard input from) multiple clients.

tmux is intended to be a modern, BSD-licensed alternative to programs such as GNU screen. Major features include:

  • A powerful, consistent, well-documented and easily scriptable command interface.
  • A window may be split horizontally and vertically into panes.
  • Panes can be freely moved and resized, or arranged into one of four preset layouts.
  • Support for UTF-8 and 256-colour terminals.
  • Copy and paste with multiple buffers.
  • Interactive menus to select windows, sessions or clients.
  • Change the current window by searching for text in the target.
  • Terminal locking, manually or after a timeout.

Installation can be made through compiling  the source code . For RedHat based distributions this utility is provided as an ready made rpm package . As far as I know “Remi” provides it . First add this repo to your repository list and let yum handle the installation .
Start a single tmux session with : tmux  and explore it’s functionality .

Default keybindings & Functionality :

The default keybindings for tmux are actually pretty intuitive, though if you’re used to screen you’ll likely get a little peeved with the default action binding of C-b, though this is easily changed to mimic screens behavior:

You can change keybinding Ctrl-b to Ctrl-a by creating a ~/.tmux.conf and putting the following into it: set -g prefix Ctrl-a . There is no tmux.conf by default.

From inside the tmux terminal
Ctrl-b c Create new window
Ctrl-b d Detach current client
Ctrl-b l Move to previously selected window
Ctrl-b n Move to the next window
Ctrl-b p               .
Move to the previous window
Ctrl-b & Kill the current window
Ctrl-b , Rename the current window
Ctrl-b % Split the current window into two panes
Ctrl-b q Show pane numbers (used to switch between panes)
Ctrl-b o Switch to the next pane
Ctrl-b ? List all keybindings

Basic Pane Handling:

One of the most powerful features tmux offers is the ability to split up your current window into “panes”.There are some basic key bindings and commands to split the terminal window (vertically and horizontally) and to switch between them

Basic pane handling
Ctrl-b % Split the window vertically
Ctrl-b : “split-window” (Split window horizontally)
Ctrl-b o             .
Goto next pane
Ctrl-b q Show pane numbers, when the numbers show up type the key to goto that pane
Ctrl-b { Move the current pane left
Ctrl-b }
Move the current pane right

Resizing Panes:

You can also resize panes if you don’t like the layout defaults. I rarely need to do this, though it’s handy to know how. Here is the basic syntax to resize panes:

Resizing Panes
Ctrl-b : resize-pane By default it resizes the current pane down
Ctrl-b : resize-pane -U Resizes the current pane upward
Ctrl-b : resize-pane -L Resizes the current pane left
Ctrl-b : resize-pane -R Resizes the current pane right
Ctrl-b : resize-pane 20 Resizes the current pane down by 20 cells
Ctrl-b : resize-pane -U 20 Resizes the current pane upward by 20 cells
Ctrl-b : resize-pane -L 20 Resizes the current pane left by 20 cells
Ctrl-b : resize-pane -R 20 Resizes the current pane right by 20 cells
Ctrl-b : resize-pane -t 2 20 Resizes the pane with the id of 2 down by 20 cells
Ctrl-b : resize-pane -t -L 20 Resizes the pane with the id of 2 left by 20 cells

Advertisements

Comments»

No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s