My tmux configuration with tmuxinator

Written by on

We're a small, remote engineering team (only 3 people), so we haven't developed a standard for our development machines yet.  We have 1 person on Mac, 1 person on Ubuntu (me), and 1 person on Manjaro (Linux).

We're always experimenting with new tools and adding new ones to our toolbox. The one I want to talk about today is tmuxinator

If you're familiar with tmux, it can be a bit of a pain to script your tmux sessions. For example, if you want one pane to run vim, another to show a log file, and a third to run the rails console, it takes a bit of time to script. 

The goal is this: When I turn on my machine in the morning, I want to type one command to do the following: 

  • Start vim in the right directory.
  • Give myself a command prompt in the right project directory. 
  • Start the Rails server. 
  • Start a tail of the development log. 
  • Start the Rails console. 
  • Start spork for running specs.

You can easily script all of this with tmuxinator

 

Using the script above, you end up with a tmux layout like so.

tmuxinator.png

When I start my terminal for the day, I run the command mux tula   and I'm off and running. A tmux session is started and I end up with the following:

  • vim running in the top window
  • a prompt on the bottom for playing with git, bundle, etc. 
  • the Rails server running on window 1
  • the development log tail on window 2
  • a Rails console on window 3

You're up and running for development in no time. 

As a bonus if you work on multiple projects, simply detach from this tmux session and run another. Your session is saved (until you restart your computer), so switching between projects is a breeze. 

I haven't played much with this layout and I'm sure it's not perfect. It's a much better solution to what I was doing in a previous life. If you have any of your own tmux layouts, I'd love to hear from you in the comments below. 

And, by the way, if you need a great tmux primer, I recommend  TMUX – The Terminal Multiplexer.