tmux is a terminal multiplexer which is a fancy way to say it allows multiple “windows” in a single terminal. It’s essential to my workflow. This post will only touch on the basics to get you up and running.

Install

$ brew install tmux

Using Windows? See here.

The Basics

Start it up

$ tmux

The leader

To use any of the commands you have to type the leader prefix followed by your specific command. The default is CTRL + B. To save space I’ll show the prefix as PX.

Creating windows

PX + c

tmux starts with a window created by default but we can open multiple within the same session. The windows are numbers starting at zero.

Switching windows

PX + 0

The above would switch to window zero. At the bottom in the status bar you’ll see each window listed. The active window is indicated with an asterisk.

Creating panes

PX + % Vertical split
PX + "" Horizontal split

Windows a kind of useless to me. I much prefer to just split a single window into multiple panes and keep everything in sight.

Switching panes

PX + ;

This will cycle from one pane to the next within the same window. Instead of ; you can also use the arrow keys.

Resizing panes

Resizing is so awkward I usually go into command mode for this.

PX + :

: resize-windows -L

L indicates the direction: left. You can also specify U, D, and R for the other four directions. Repeat this command as needed.

Detach

PX + d

This will detach the session, close tmux, but leave your session running in the background.

Customize

vim copy and paste

You can get lost for weeks configuring this stuff but here is a basic setup that’ll let you copy and paste like you do in vim. The config is here: ~/.tmux.conf

set-window-option -g mode-keys vi
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection

Disable the mouse

The prevent accidental scrolling and trashing your tmux session I recommend you immediately disable the mouse.

PX + :

: setw -g mode-mouse off

Advanced

I haven’t really even scratch the surface. After you’ve been using tmux for a while you’ll want to customze your status bar and start messing with powerlines glyphs. To learn how to do that and get a cooler setup I recommend you read tmux 2 Productive Mouse-Free Development.