Using tmux and tmuxinator
3 min read
This is what I have been using for a couple weeks now and it’s so amazing, I have to share it with you. Up until a few months ago, I was using the standard command line of my OS. Now, there’s nothing wrong with it, but I always like to work on improving my tools.
For one, switching tabs in the terminal was inconvenient. Then the different tab setup every day made it hard to get used to a specific pattern. This is no longer a problem with tmux and tmuxinator.
Tmux is short for terminal multiplexer which is a fancy way for saying that it allows you to switch between multiple programs in one terminal. Tmux can do much more, but I am going to focus on window management for this post.
Tmuxinator allows you to easily script tmux sessions. I am using tmuxinator to setup different window layouts for each of my projects.
Tmux windows and panes
The idea of tmux is that you have one single terminal window with multiple tabs inside. In each tab you have the ability to split up your window into multiple panes.
To start a simple tmux session just run
You can open new tabs with ctrl + b + c and close them with ctrl + b + x.
To switch between tabs use ctrl + b + tab-number.
Open new panes with ctrl + b + % / ".
To switch between panes use ctrl + b + o
Tmux configuration is saved in
~/.tmux.conf. I recommend adding the following lines to your configuration since the defaults aren’t really nice.
Also, here is a great cheatsheet for the most important tmux shortcuts.
Save time with tmuxinator
Tmux comes with an extensive command line interface, but it can be a little bit difficult to figure out. Tmuxinator makes use of the commands that tmux comes with, but it extracts all the complexity into a single yaml file:
With this file in place, you can now run
mux railsproject and everything will be started automatically.
This is liberating in so many ways. In the morning, you don’t have to remember what tools you need for the project you’re working on. Throughout the day you can rely on keyboard shortcuts always bringing you back to the same program. And then you quickly get used to the patterns with your project specific settings. I found that I can stay focused way better this way. The tab for logs, server, console and editor are always the same.
I encourage you to give tmux and tmuxinator a try. If you happen to run into problems, feel free to leave a comment and I will see what I can do.
You can find my whole .tmux.conf here. Additionally some of my tmuxinator configuration files are located here.10 Mar 2014