Tmux Advanced Tutorial: 3 Tips and Tricks to Improve Your Efficiency
This advanced Tmux tutorial is based on the Office Hours hosted by Codementor Bruno Sutic, who created the Tmux Plugin Manager along with various Tmux plugins. Tmux is a terminal multiplexer that enables a number of terminals (or windows). Each terminal runs a separate program that can be created, accessed, and controlled from a single screen. It is a popular secret weapon of many experienced developers.
The text below is a summary done by the Codementor team and may vary from the original video and if you see any issues, please let us know!
Tip #1: Trimming your tmux.conf file
If your tmux.conf
file has over 200 lines of code (LOC), then it’s too big and definitely unmanageable. I’d suggest complying to community standard key bindings using plugins. For example, I think the plugins I wrote can shave off about 50 LOC. Another solution is to build your own plugin to trim your file.
Tip #2: Create as Many Sessions and Windows as You Want
You see a lot of recommendation to maintain a list of windows and panes to keep your sessions manageable, to kill any windows that you don’t need for a project and keep a strict window layout. However, I think that is an unnecessary waste of time.
Terminals are “cheap” so you should be able to create windows and sessions liberally, and you shouldn’t need to manage or delete unused panes, windows or sessions. That is maintenance work you don’t need to do with tmux. Have 1 session per project and create window layouts on the go, since everything in tmux is fast and easy.
Tip # 3: Have Session-Name Completion to Switch Sessions in an Instant
The recommended way to switch sessions quickly is to use the tmux-sessionist plugin, where prefix + g
will tell tmux to prompt for a session name instead of requiring you to visually parse things, which will take much longer. The tmux-sessionist plugin will allow you to have session-name completion so you can instantly switch sessions.
Codementor Bruno Sutic has been developing with Rails and Backbone.js for most his career. He contributed to a popular git-extras project and created the Tmux Plugin Manager on top of git along with other Tmux plugins.