Manage different tmux configurations with tmuxinator

  18 Sep 2014


Usually, we can create a new session and run a bunch of tmux command by loading tmux configuration file:

From the above configuration, you could start and attach to the session like so:

tmux -f fu.conf attach

This way, you will learn how tmux commands work. It’s pretty good. But, managing tmux configuration with tmuxinator seems easier for more complicated layout and still has the flexibility. Doing so, you just have to define what you need in YAML file, e.g. window, pane, command etc.

Run the following commands to install tmuxinator gem install tmuxinator rbenv rehash #only if you use rbenv without auto rehash.

And check if you have required env var set

tmuxinator doctor

I got this output:

Checking if tmux is installed ==> Yes
Checking if $EDITOR is set ==> No
Checking if $SHELL is set ==> Yes

That means I have to set $EDITOR variable, i.e. export EDITOR=”vim” or add this to ~/.bashrc or ~/.zshrc )

Then, try to check again tmuxinator doctor

Checking if tmux is installed ==> Yes
Checking if $EDITOR is set ==> Yes
Checking if $SHELL is set ==> Yes

The output looks good now.

Assume, we would like to create a project name dev. Let’s create a new tmuxinator project.

tmuxinator open dev

tmuxinator will generate ~/.tmuxinator/dev.yml file. For my Rails project, I have the config file that looks like this:

And you may notice the layout key looks scary but it is just the output of tmux list-windows. Otherwise, you may use those supported layout name including even-horizontal, even-vertical, main-horizontal, main-vertical, tiled

That’s it! it’s simple and very flexible way to manage your tmux configurations.

comments powered by Disqus