Tmux - A quick guide
Posted on Feb 1, 2016 by Ezequiel Maraschio
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:
Ubuntu/Debian
Basic usage
With tmux
you can create multiple sessions, so you can have a different environments on each of it.
Start 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
Attach to an existing session
List all sessions
Detach from session
Kill 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
So now you can do: Ctrl-b , and the type a window name for this tab Ctrl-b & for kill this tab
Panes (splits)
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
Rebind pane splitting
So now you can do: Ctrl-a | for split vertical Ctrl-a - for split horizontal
Change history limit
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.