engineering, shorts,

Tmux Cheatsheet

Awin Awin Feb 07, 2019 · 3 mins read
Tmux Cheatsheet
Share this

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 ubuntu
sudo 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:

tmux session

  1. Press Ctrl+b and then press % to split vertically.
  2. Press Ctrl+b and then press " to split horizontally.
  3. Press Ctrl+b and then o twice, to switch panes to top right pane.`
  4. 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.

<prefix> : resize-pane -L 20
<prefix> : resize-pane -R 20
<prefix> : resize-pane -U 20
<prefix> : resize-pane -D 20

Copy mode

Use <prefix> [ to get into copy mode and you can move around with arrow keys.

This is useful to scroll through log files.

Hit the ENTER key to get out of the copy mode.

Show a clock

<prefix> t

Shows a clock in the pane.

Close tmux session

Close the tmux session with the following command:

<prefix> : kill-session

Credits: Header photo by Christian Fregnan on Unsplash.

Awin
Written by Awin Follow
Hi, I am Awin, founder at Neumeral. Please reachout to me for any feedback / questions.