tmux

Overview

tmux is my current replacement for screen. I use it locally under iTerm and remotely over SSH (including on mobile devices).

Synchronized Input To Multiple Panes

Toggle synchronized pane input (send same commands to all panes in a window):

:setw synchronize-panes

Saner Resizing With Multiple Clients

Constrain window size only when necessary:

setw -g aggressive-resize on

Peeking At A File

Handy helper (split window to edit or view a file):

peek() { tmux split-window -p 33 "$EDITOR" "$@" || exit; }

Re-attaching A Lost Session

Recreate the socket then attach:

killall -s SIGUSR1 tmux
tmux attach

Mouse Support

Example options (adjust for tmux version):

# tmux 2.1+ (example)
set -g mode-mouse
# tmux 1.8 (legacy example)
set -g mode-mouse on
set -g mouse-resize-pane on
set -g mouse-select-pane on
set -g mouse-select-window on

Cursor Key Pane Switching (No Repeat)

Remove repeat semantics:

bind-key Up    select-pane -U
bind-key Down  select-pane -D
bind-key Left  select-pane -L
bind-key Right select-pane -R

Base Config

Below is the base ~/.tmux.conf I often start from:

# make mouse useful in iTerm
set -g mouse-select-pane on

# automatically set window title
setw -g automatic-rename

# act like vim
setw -g mode-keys vi
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind-key -r C-h select-window -t :-
bind-key -r C-l select-window -t :+
bind < resize-pane -L 4
bind > resize-pane -R 4
bind - resize-pane -D 4
bind + resize-pane -U 4

# disable repeat on cursors
bind-key Up    select-pane -U
bind-key Down  select-pane -D
bind-key Left  select-pane -L
bind-key Right select-pane -R

# look good
set -g default-terminal "screen-256color"

# status indicators
#set -g status-right '#(uptime | cut -d, -f 2-)'

#### COLOUR

# default statusbar colors
set-option -g status-bg colour235 #base02
set-option -g status-fg colour136 #yellow
set-option -g status-attr default

# default window title colors
set-window-option -g window-status-fg colour244
set-window-option -g window-status-bg default
#set-window-option -g window-status-attr dim

# active window title colors
set-window-option -g window-status-current-fg colour166 #orange
set-window-option -g window-status-current-bg default
#set-window-option -g window-status-current-attr bright

# pane border
set-option -g pane-border-fg colour235 #base02
set-option -g pane-active-border-fg colour240 #base01

# message text
set-option -g message-bg colour235 #base02
set-option -g message-fg colour166 #orange

# pane number display
set-option -g display-panes-active-colour colour33 #blue
set-option -g display-panes-colour colour166 #orange

# clock
set-window-option -g clock-mode-colour colour64 #green

Quick Install (Historical Notes)

Legacy build steps for older systems:

  1. Download libevent (historical version 2.0.12 referenced).
  2. Download tmux source (historical version 1.4 referenced).
  3. Build both (make) in order and install.

See also: ,

This page is referenced in: