One of my most popular posts used to be my tmux config. Seems suitable to start this new blog with a similar post :)

tmux is a terminal multiplexer. Think of it as a terminal window manager. Once you start using it, especially for remote sessions, it’s hard to go back.

It also used to be much more efficient than screen, although I don’t know whether this is still the case. In my original post over a decade ago I wrote:

Clean config file, thorough documentation and a few nice touches here and there (i.e. better, persistent window splitting) make it a nice alternative to screen, but the biggest difference lies in memory usage. Screen can easily eat up to 40-50mb with just a few windows open, but tmux has yet to reach the 10mb mark!

Anyway, with some configuration adjustments, you can make tmux a little nicer to use:

  • switch the prefix key to `
  • switch the base index to 1 instead of 0
  • make the status bar a little more useful
  • increase the history size

Here’s how it looks:

tmux

Here’s my ~/.tmux.conf:

# ` is an interesting key for a prefix
set-option -g prefix `

unbind-key C-b
bind-key C-a last-window
bind-key ` last-window
# we still need a way to actually type ` => `a
bind-key a send-prefix

# I've never needed this, but being able to switch
# back to CTRL-A is not a bad idea.
bind-key F11 set-option -g prefix C-a
bind-key F12 set-option -g prefix `

# 0 is too far from ` ;)
set -g base-index 1

set-option -g status-keys vi
set-option -g bell-action any
set-option -g set-titles on
set-option -g set-titles-string '#H:#S.#I.#P #W #T' # window number,program name,active (or not)
set-option -g visual-bell off

setw -g mode-keys vi
setw -g monitor-activity on

bind e previous-window
bind f next-window

set-option -g status-justify left
set-option -g status-bg default
set-option -g status-fg white
set-option -g status-left-length 40
set-option -g status-right-length 80

set -g window-status-style bg=default
set -g window-status-bell-style fg=red,bold
set -g window-status-current-style fg=green
set -g window-status-activity-style fg=yellow

set -g status-left '#[fg=red]#H#[fg=green]:#[fg=white]#S #[fg=green]][#[default]'

set -g status-interval 5
set -g status-right '#[fg=green]][#[fg=white] #(cat /proc/loadavg) #[fg=green]][ #[fg=yellow]%H:%M#[default]'

set -g history-limit 100000

bind r source-file ~/.tmux.conf