Quickstart tmux

Tmuxifying terminal life

I haven’t been using tmux since I’m a happy user of iTerm2. Eventhough tmux had been used in servers I used to work with, I preferred avoiding it because of the fallacious assumption that it would be hard to remember all those scary key-shortcuts. I gave it a try today, and totally regret for not learning it earlier.

Why tmux?

tmux is a terminal multiplexer. It enables to run multiple processes in one terminal.

With tmux you can create multiple sessions in a terminal, each session can have multiple windows which can be split into panes. Sessions can be attached/detached to the working terminal. This is heavily useful for multiuser concurrent system-terminals.

Another advantage is that processes running inside tmux sessions can continue even after closing the terminal.

Installation

In OSX, tmux can be installed with homebrew.

$brew install tmux

console

Typing tmux will start a new session, you can see the session status displayed on the bottom bottom of the window in a green bar.

$tmux

When you are inside tmux session, every tmux command need to have a prefix. By default it is CTRL+B. For example, commands below does splitting window into vertical panes.

CTRL+B %

Here is a list of useful commands,

Prefix

Command

Use

CTRL+B

Sessions

s

list sessions

:new<ENTER>

create new session

$

rename session

d

detach session

Windows

w

list windows

f

find window

c

create window

&

kill window

,

rename window

n

next window

p

previous window

Panes

%

vertical split

"

horizontal split

q

show pane numbers, if pane number is typed immediately, control is switched to that pane

x

kill pane

z

toggle zoom pane

<ARROW KEY>

switch to pane pointed by arrow key

o

swap panes

{

move current pane to left

}

move current pane to right

<SPACE BAR>

toggle between different pane layouts

Extras

t

show time

?

list shortcuts

:

prompt

As mentioned in the last entry of table above, CTRL+B : will give tmux prompt at the bottom of the window, you can enter commands there.