Tmux Cheatsheet

Tmux allows you to run multiple terminal sessions in a single terminal window or a remote terminal, and allows you to split panes, switch windows and much more.

By Awin Abi

Last updated on February 7, 2019

tmux is a terminal mutiplexer, which allows you to run multiple terminals in a single local or remote terminal window. It comes in pretty handy when you want to see multiple terminal at once say with split panes.

I switch editors, whenever I feel a little nerdy to use vim with tmux. And I search for tmux commands every time. So I’ve put together just the basics commands, in this tmux cheatsheet.

Installation

If you are just getting started with tmux follow these steps to install tmux in your development machine.

# In ubuntusudo apt-get install tmux
# In MacOS
brew install tmux

Some basics

After installing tmux, open up a terminal and type tmux to start a tmux session. Then press the following shortcuts to make it look like this:

Press Ctrl+b and then press % to split vertically.

Press Ctrl+b and then press " to split horizontally.

Press Ctrl+b and then o twice, to switch panes to top right pane.

Press Ctrl+b and then press t to show a clock.

You can use the sequence Ctrl+b and then o to move around the panes. Ctrl+b is the default prefix in tmux. Lets break it down, command by command.

Sessions

Create a new tmux session by name

tmux new -s <session-name>

Attach to a tmux session

tmux a
tmux a -t <session-name>

List sessions

tmux ls

Windows

The default prefix key for tmux is Ctrl+b. First hit the prefix and then execute the tmux commands.

Create a new window

<prefix> c

Next and previous windows

<prefix> n
<prefix> p

Kill a window

<prefix> &

Panes

Create a vertical split

<prefix> %

Create a horizontal split

<prefix> "

List all panes

<prefix> q

When the pane numbers are displayed, hit the number to switch to that pane.

Kill a pane

<prefix> x

Switch between panes

<prefix> o

Resize current pane

<prefix> + : brings up a command line in tmux, then type the rest of the command in the prompt. Resize the pane left, right, up, down.