Key bindings may be changed with the bind and unbind commands in {{ic|tmux.conf}}. For example, you can change the prefix key (i.e. {{Ic|Ctrl-b}}) to {{Ic|Ctrl-a}} by adding the following commands in your configuration file:

Key bindings may be changed with the bind and unbind commands in {{ic|tmux.conf}}. For example, you can change the prefix key (i.e. {{Ic|Ctrl-b}}) to {{Ic|Ctrl-a}} by adding the following commands in your configuration file:

−

unbind C-b

+

{{bc|

−

set -g prefix C-a

+

unbind C-b

+

set -g prefix C-a

+

}}

Additional ways to move between windows include:

Additional ways to move between windows include:

Revision as of 12:44, 28 February 2012

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.

Tmux is a "terminal multiplexer: it enables a number of terminals (or windows), each running a separate program, to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached."

Tmux is notable as a BSD-licensed alternative to GNU Screen. Although similar, there are many differences between the programs, as noted on the tmux FAQ page. Most notably, tmux is currently under active development, in contrast to screen, which has not had a stable release since August 8, 2008.

Install

Configure

A user-specific configuration file should be located at ~/.tmux.conf, while a global configuration file should be located at /etc/tmux.conf. Default configuration files can be found in /usr/share/tmux/.

Key bindings

Prefix all commands withCtrl-b

Cmd

Action

c

Create a new window

n

Change to next window

p

Change to previous window

"

Split pane horizontally

%

Split pane vertically

,

Rename current window

o

Move to next pane

By default, command key bindings are prefixed by Ctrl-b. For example, to vertically split a window type Ctrl-b %.

After splitting a window into multiple panes, you can resize a pane by the hitting prefix key (i.e. Ctrl-b) and, while continuing to hold Ctrl, press Left/Right/Up/Down. Swapping panes is achieved in the same manner, but by hitting o instead of a directional key.

Tip: To mimic screen key bindings copy /usr/share/tmux/screen-keys.conf to either of the configuration locations.

Key bindings may be changed with the bind and unbind commands in tmux.conf. For example, you can change the prefix key (i.e. Ctrl-b) to Ctrl-a by adding the following commands in your configuration file:

unbind C-b
set -g prefix C-a

Additional ways to move between windows include:

Ctrl-b l (Move to the previously selected window)
Ctrl-b w (List all windows / window numbers)
Ctrl-b <window number> (Move to the specified window number, the default bindings are from 0 – 9)
Ctrl-b q (Show pane numbers, when the numbers show up type the key to goto that pane)

What if you have 10+ windows open? Tmux has a find-window option & keybinding.

If you enable xterm-keys in your tmux.conf, then you need to build a custom terminfo to declare the new escape codes or applications will not know about them. Compile the following with tic and you can use "xterm-screen-256color" as your TERM:

# A screen- based TERMINFO that declares the escape sequences
# enabled by the tmux config "set-window-option -g xterm-keys".
#
# Prefix the name with xterm- since some applications inspect
# the TERM *name* in addition to the terminal capabilities advertised.
xterm-screen-256color|GNU Screen with 256 colors bce and tmux xterm-keys,
# As of Nov'11, the below keys are picked up by
# .../tmux/blob/master/trunk/xterm-keys.c:
kDC=\E[3;2~, kEND=\E[1;2F, kHOM=\E[1;2H,
kIC=\E[2;2~, kLFT=\E[1;2D, kNXT=\E[6;2~, kPRV=\E[5;2~,
kRIT=\E[1;2C,
# Change this to screen-256color if the terminal you run tmux in
# doesn't support bce:
use=screen-256color-bce,

Session initialization

You can have tmux open a session with preloaded windows by including those details in your ~/.tmux.conf:

Scrolling issues

If you have issues scrolling with Shift-PageUp/Shift-PageDown in your terminal, try this:

set -g terminal-overrides 'xterm*:smcup@:rmcup@'

ICCCM Selection Integration

It is possible to copy a tmux paste buffer to an ICCCM selection, and vice-versa, by defining a shell command which interfaces tmux with an X11 selection interface. The following tmux config file snippet effectively integrates CLIPBOARD with the current tmux paste buffer using xclip:

Note: At first you may read screen as if we were using screen and not tmux, but tmux also uses screen for the TERM enviroment variable.

This snippet does the same thing, but also checks tmux is installed before trying to launch it. It also tries to reattach you to an existing tmux session at logout, so that you can shut down every tmux session quickly from the same terminal at logout.

# TMUX
if which tmux 2>&1 >/dev/null; then
# if no session is started, start a new session
if test -z ${TMUX}; then
tmux
fi
# when quitting tmux, try to attach
while test -z ${TMUX}; do
tmux attach || break
done
fi

Note: Instead of using the bashrc file, you can launch tmux when you start your terminal emulator. (i. e. urxvt -e tmux)

Use tmux windows like tabs

The following settings added to ~/.tmux.conf allow to use tmux windows like tabs, such as those provided by the reference of these hotkeys — urxvt's tabbing extensions. An advantage thereof is that these virtual “tabs” are independent of the terminal emulator.

Clients simultaneously interacting with various windows of a session

Note: Since tmux 1.4 mirrored sessions may be set to auto-destroy with the destroy-unattached session option

To avoid these issues he wrote the script “tmx” — the version below is slightly modified to execute “tmux new-window” if “1” is its second parameter. Invoked as tmx <base session name> [1] it launches the base session if necessary. Otherwise it will kill any “zombie” sessions, launch a new “client” session linked to the base, optionally add a new window and attach. Then it waits for detachment and kills its session.

added to ~/.tmux.conf. It causes tmux to resize a window based on the smallest client actually viewing it, not on the smallest one attached to the entire session.

Changing the configuration with tmux started

By default tmux reads ~/.tmux.conf only if it was not already running. To have tmux load a configuration file afterwards, execute:

tmux source-file <path>

This can be added to ~/.tmux.conf as e. g.:

bind r source-file <path>

Template script to run program in new session resp. attach to existing one

This script checks for a program presumed to have been started by a previous run of itself. Unless found it creates a new tmux session and attaches to a window named after and running the program. If however the program was found it merely attaches to the session and selects the window.