A few months ago, I had a discussion with a colleague about how iTerm2 deals with split and tabs and this guy mentioned me a really good tool call tmux.

He said: tmux is like a console over a console. You can do everything. The split thing is just another feature of that…

So I came back to my place and I did some research about this tool and here is my summary.

What is it?

Based on tmux page:

Tmux is a terminal multiplexer. What is a terminal multiplexer? It lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal. And do a lot more.

How to install

Mac OSX

If you use Homebrew just:

brew install tmux

Ubuntu/Debian

sudo add-apt-repository ppa:pi-rho/dev
sudo apt-get update
sudo apt-get install tmux

Basic usage

With tmux you can create multiple sessions, so you can have a different environments on each of it.

Start tmux

tmux

After that you will notice that the console has a green bar at the bottom (this command will create a blank session by default)

Session Management

The main idea on tmux is having multiple sessions open and being able to disconnect and reconnect to them as desired, for that you can execute this set of commands:

Create new session

tmux new -s my-session

Attach to an existing session

tmux a -t my-session

List all sessions

tmux ls

Detach from session

tmux detach

Kill session

tmux kill-session -t my-session

Windows and Panes Managment

The binding for command key by default is Ctrl-b, so you need to press it before each instruction.

Here is the list of instruction to play with windows and panes:

Windows

c  create window
w  list windows
n  next window
p  previous window
,  name window
&  kill window

So now you can do: Ctrl-b , and the type a window name for this tab Ctrl-b & for kill this tab

Panes (splits)

%  vertical split
"  horizontalI split
x  kill pane

So now you can do: Ctrl-b % for split vertical Ctrl-b “ for split horizontal

Advanced configuration

Of course you can customize each configuration setting with a .conf file.

Just create .tmux.conf file on your home and you can set a lot of things, for example:

Rebind Ctrl-b

set-option -g prefix C-a

Rebind pane splitting

unbind %
bind | split-window -h
bind – split-window -v

So now you can do: Ctrl-a | for split vertical Ctrl-a - for split horizontal

Change history limit

set-option -g history-limit 10000

For mastery this kind of stuff I really recommend this book

Conclusion

The goal of this article is to get you going with this tool in as simple a way as possible and show you the basic utilities.

I am now at the point where I start tmux up to do all of my console tasks and I cannot live without him.

There are a ton of articles about tmux over the web. I started with this tool just for split view / tabs and now I love it!

I suggest you experiment with him and discover what fits your daily work. I compiled a list of resources and plugins to move on.

Resources

The Tao of tmux

Tips

Configuration Examples

Configuration Examples

Extensions

tmuxinator

tmux-resurrect