Tmux basics
Tmux is a Terminal Multiplexer. It allows you to organise your terminal by splitting your work across multiple windows and panes.
This is a basic guide on getting up to and running quickly to allow you to work more effectively.
Concepts
Tmux organises itself around the concepts of Sessions, Windows and Panes.
A session can contain one or more windows, and windows can be split into one or more panes. By default, when you create a new tmux session, it will have once window.
Creating a new session
From a terminal, launch a new tmux session with the following command:
$ tmux
You can also create a named sessions. This is useful if you have multiple sessions where you can reference one easily.
$ tmux new -s my-session
Working with windows and panes
Once you are inside a session. It’ll seem pretty familiar and you’ll work away in the terminal like you would normally do. What you see in front of you is the window of your current session. You may at some point want to split the window into panes. You have the choice of splitting it vertically or horizontally. To do that, you’ll enter the bind key, followed by the command.
The bind key is configurable, but be default it is control+b
or <C+b>
for short.
Split the window vertically
<C+b> %
Split the window horizontally
<C+b> "
You can then switch between panes by using <C+b> o
to go to the next pane. If you want to close a pane, enter <C+b> x
when the pane you want to close is active.
Detaching from a session
Detaching from a session <C+b> d
allows you to enter that session another time. Everything about the session will be remembered when you resume.
With the session detached, use the following to list the sessions.
$ tmux ls
0: 1 windows (created Tue Jun 2 13:07:29 2020)
The resume the session with
$ tmux attach-session -t 0
Conclusion
That’s pretty much all you need to get going with tmux. There is a load more that you can do with it that is beyond the scope of this post. Checkout the Github repo for documentation on usage.