ZNHOO Whatever you are, be a good one!


  1. Overview
  2. Configuration
  3. Try Tmux
  4. Tmux Sub-commands
  5. Tmux Command Key Bindings


Tmux has sessions, windows (term tabs), and panes (rectangle area on screen). Each session a few windows, each window a few panes. We can regard Tmux Window and Pane as Emacs Frame and Window. User can see only one window at a time. Usually, a window is splitted into multiple panes, allowing jumping back and forth.


# /etc/tmux.conf
# ~/.tmux.conf

# copy mode
#setw -g mode-keys emacs
setw -g mode-keys vi

# Mouse support - set to on if you want to use the mouse
* setw -g mode-mouse off
* set -g mouse-select-pane off
* set -g mouse-resize-pane off
* set -g mouse-select-window off

# Set the default terminal mode to 256color mode
set -g default-terminal "screen-256color"

# enable activity alerts
setw -g monitor-activity on
set -g visual-activity on
setw -g monitor-silence 30
set -g visual-silence on

# Center the window list
set -g status-justify centre

# scrollback limit
set-option -g history-limit 100000

# bring ssh-agent to tmux

To configure solorized color theme, check tmux-colors-solarized.

Try Tmux

Start new session:

~ $ tmux new-session -s session-name

To put Tmux background, we detach by Ctrl-b d shortcut.

List and kill session:

~$ tmux ls
~$ tmux kill-session -t session-name

Attatch to session:

~ $ tmux a | at | attatch
~ $ tmux a -t session-name

Tmux Sub-commands

Tmux has many sub-commands, like new-session, kill-session and attach-session above. Use tmux list-commands to show all supported sub-commands.

Many sub-commands has built-in aliases, like new for new-session. We can also just type a few leading characters of a sub-command as long as no ambiguity incurred. For example, attach-session can be expressed as just a single character a or a simple word att.

Once attached to a session, we can use key bindings to trigger sub-commands within the session. We call those key bindings command key bindings. Command key bindings share the same prefix key Ctrl-b. For example, to create a window for the session, use Ctrl-b c.

We can also manually input sub-commands within a session. Use Ctrl-b : to get into command mode, and then input the sub-command. For instance, Ctrl-b : source-file ~/.tmux.conf reloads Tmux configuration on the fly. If you mis-typed a sub-commands, then Ctrl-u and try again. To get out of command mode, just press ESC.

Tmux Command Key Bindings

Apart from command mode, Tmux has the copy mode by Ctrol-b [. Copy mode is used to navigate within shell screen in casef we don't have X (i.e. scroll up). Copy mode has its own key bingdings. By default, Tmux uses Emacs-like key bindings and gets out ESC. You can change to Vi style and get out by ENTER.

Check supported key bindings of copy mode by tmux list-keys -T copy-mode (without -T, list all Tmux key bindings). You will find that only part of Emacs or Vi key bindings are supported.

The following are some general Tmux key bingdings and the corresponding sub-commands.

Session operation:

: command mode
[ copy mode

s  list sessions
$  rename a session

Window operation:

c  create window
w  list windows
n  next window
p  previous window
f  find window
&  kill window

Pane operation:

%  vertical split
"  horizontal split

o  swap panes
x  kill pane
+  break pane into window (e.g. to select text by mouse to copy)
-  restore pane from window
⍽  space - toggle between layouts
q (pane numbers will show up on screen. When the numbers show up, press the relevant key, switching to that pane)
{ (Move the current pane left)
} (Move the current pane right)
z toggle pane zoom

Misc operation:

d  detach
t  big clock
?  list shortcuts