Tmuxinator

February 22, 2021

I wanted to share a tool I use daily, that does what does so well that I sometimes even forget that it’s there.

Tmuxinator is a wrapper around Tmux that lets you create and manage sessions really easily.

Let’s say that you have a project that you want to open in Tmux and you have two windows, one window contains a full screen editor and the other window is vertically split with logs on one side and a shell on the other. The traditional way to do this is to either do it manually or create a shell script that will run those manual steps for you in order.

Tmuxinator makes this much more simple by handling creation for you from a Yaml config file. Here’s a config based on the example above:

name: project
root: ~/project
windows:
	- editor: vim
	- output:
		layout: even-vertical
		panes:
			- tail -f log/development.log
			- {}

(A default config is created when you run tmux new [project_name])

This creates a named session called project with two windows, named editor and output. The editor window runs vim whilst the output window uses the even-vertical layout to display a pane tailing logs and another pane in which no commands are ran.

To create the session and start working, you run mux project. That’s it.

In addition, future invocations of mux project will attach to the open session, rather than creating a new one. This even works when you are already in another Tmux session (it just changes which session you are attached to).

I mainly use this to set up Tmux sessions for each work related project I am working on and switch between them (the mux stop [project_name] works well to kill any sessions you’re not working on anymore).