Using the iTerm 2 and tmux integration

John John (304)
5 minutes

For a few years now, I've been using iTerm 2 and tmux. But only recently did I find out about a pretty important feature of iTerm: tmux integration. I found out because I was getting tired of tmux as a window manager and started looking for alternatives.

The tmux integration basically means that you use iTerm 2 as you normally would for window management, except it uses tmux on the backend for multiplexing.


tmux -CC
tmux -CC attach
Posted in these interests:
h/unix13 guides
h/linux41 guides
h/tmux1 guide

You can download iTerm 2 from the website.

tmux must be installed on whichever machine you plan to use it.

On OS X:

brew install tmux


apt-get install tmux
Start new tmux session using -CC option

Using iTerm 2, log into the machine you want to work with. This can be your local machine or a remote server over ssh. Start a new tmux session using the -CC option.

tmux -CC

You will see a message saying tmux mode started with a Command Menu.

Open new tabs and windows

With this setup iTerm is your window manager. So if you're going to open new tabs, split panes, or open new windows you do so using all of the shortcuts you may be familiar with:

cmd + t: open a new tab cmd + n: open a new window cmd + d: split vertically cmd + shift + d: split horizontally

You can choose whether you want to do this using the same profile or not. If you choose to use the same profile, iTerm will use tmux to create virtual windows.

Detaching tmux

When you're done working and you're ready to detach you can simply close the tab or window. iTerm will ask you whether you want to detach tmux or kill the windows. Clicking Detach tmux Session will cleanly detach and allow you to re-attach in the future.

If you've got a tmux session already running and you want to attach, simply use:

tmux -CC attach
John John (304)

If you're familiar with Python's keyword-only arguments, then you've probably wondered why the same constraint doesn't exist for positional arguments. This changes with Python 3.