William Vaughn

The tmux manual review

The tmux manual is extensive, well written, and informative. It is an excellent reference document, but I don’t think it is particularly well-suited to teaching the concepts of tmux and how those concepts can be used as part of a user’s personal workflow.

The most useful thing I can say to the uninitiated person curious about tmux is:

Tmux does for terminal windows what your Desktop OS does for application windows. It helps you organize, partition, and navigate your terminal windows in a way that allows you to background tasks and switch your focus effectively.

If you consistently have more than two terminal windows or tabs open, you can benefit from the hour or so it takes to learn the basics of tmux. Here are a few links to get you going.

You are also welcome to use my .tmux.conf as inspiration for your own. It is available here.

Concepts

Here is the hierarchy of the tmux system.

When “attaching” to tmux, you do so as a client of the server. The server contains multiple named sessions which it can share amongst clients. Each session has a collection of windows and panes. For me, sessions are how I organize my projects. I usually have a tmux session available for each project I’m working on. Switching sessions equates to switching projects. This way I’m focusing on one project/session at a time, but can easily switch to another when I need to without losing my progress. Within a session, I keep multiple windows that help me organize the different subtasks I have to do related to the project. This could be things like starting a webserver or a text editor. Finally, panes are for viewing two terminal instances next to each other on the same screen. You can have your text editor open on the left pane, and the command line open on the right pane.

The Tao of Tmux book has some excellent visualizations which help clarify this organization of terminal instance.

Basics of tmux

The prefix

The prefix is a key combination which signals that you want to do something within tmux. Before typing a tmux command, you always hit the prefix first. The default prefix is C-b.

Essential commands

Once you’ve hit the prefix, then you can hit another key or set of keys to perform an action in tmux.

command description
? Show all the available tmux commands
s Opens menu to switch sessions
d Detach from session
c Create a new window
n Next window
p Previous window
% Vertical split window into panes
" Horizontal split window into panes
Up Down Left Right Navigate panes
x Close pane (with confirm)
& Close window (with confirm)
, Rename window
: Execute commands
swapw -s 1 -t 0 Swap windows
neww -c <path> -n <name> Create a new window and set its name and cwd
[ Enter copy mode

See the manual for more about copy mode. One way I use this copy mode is to dump all of my interesting terminal output to a file that I want to save or share.

About session managers

There are a few session manager tools out there for tmux, and all of them address the central issue of being able to save tmux session configurations. It can be a drag to restart your computer and then try to tmux at -t my-project only to find that all of the windows and panes that you so carefully created have been annihilated. Using a session manager can help alleviate that pain. My personal favorite is tmuxp because it is written in python and has the tmuxp freeze feature to export the current session to a file. Session managers are not required, you don’t have to install one right away. Go try tmux for a while, if you find that you get annoyed when you lose a session – install a session manager!

Conclusion

I can’t emphasize enough that you should take a few hours to read The Tao of Tmux book. It is a much more thorough walkthrough of tmux concepts than I gave here. It has illustrations and examples that will illuminate the ways you can use tmux to do whatever fits your workflow. Best of luck on your journey with tmux! Thanks for reading!