Tmuxinator is a way to easily manage tmux sessions. This guide will assume you have tmux and ruby gems installed.

Start by installing tmuxinator.

gem install tmuxinator

Tmuxinator will use you default editor so make sure it’s set.

export EDITOR=vim

Find where the tmuxinator executable was saved.

find . -name tmuxinator 2>&1 | grep -v "Permission denied"

The above command finds any file or directory named “tmuxinator” and pipes the output to a grep that leaves out any results that contain “Permission denied”

When you find the path to the tmuxinator command then add it to your $PATH. I keep my path in .bash_profile, but you can update your path with the following command.

export PATH=$PATH:path/to/tmuxinator

If you do have a ~/.bash_profile or ~/.bashrc file that you want to use then you can add the above line to it. You can also set an alias for tmuxinator there since it’s kind of long.

alias mux='tmuxinator'

add the above line to your .bash_profile and run source ~/.bash_profile to refresh your environment. (This didn’t quite work for me the first time. You may have to restart your terminal)
Now let’s make a new tmux session (I know we just made an alias, but for clarity’s sake, I’m going to use the full command name)

tmuxinator new foo

If you set your default editor above it should open up a yml file in your default text editor. Have a look around the file. We’ll keep it the way it is for now. Save and quite when you are done checking it out. Now in the terminal you can run this session with the following command.

tmuxinator foo

It’s as simple as that! You can use bind s to switch between sessions. bind is the key combination that you will use to do basically all tmux commands. The default is ctrl-b I believe. So ctrl-b s will let you switch between session. foo may be your only session unless you opened up a default session before you opened foo. If foo is your only session then this won’t be meaningful, but imagine you have a whole list of sessions. To be able to quickly choose another session you may want to use j and k instead of the arrows keys (vim style). To do that you may have to add the following line to ~/.tmux.conf.

set-window-option -g mode-keys vi

Restart tmux to make it go into effect. Command-t exits tmux (I found that out on accident), but if that doesn’t work you may have to kill your tmux processes and then start tmux again. See my post about killing processes here.

Being able to use vi commands will also be helpful when you use bind [. This command will allow you to traverse output. Let’s say you are compiling your code or running a server and it errors, but the pane is too small to show all of it. bind [ will allow you to move up in the window to see the above output. If you have your mode-keys set to vi then you can use j, k, h, and l to move around the output.

You can kill your session with command

tmux kill-session -t foo

You can use command-line arguments in your yml session files.


name: foo
root: ~/


tmuxinator foo bar will open up a session and place you in the ~/bar directory.

There are a few handy things you may want to add to your ~/.tmux.conf

bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

bind J resize-pane -D 5
bind K resize-pane -U 5
bind H resize-pane -L 5
bind L resize-pane -R 5

In tmux you can do commands that change your environment with bind :
select-pane -D and resize-pane -D 5 (can also just be resize-p) are the type of commands you can do in your window with bind :
the above lines make those commands possible with quick hot keys so now instead of bind :resize-pane -D 5 to resize your pane you can simple do bind J. bind J will take you to the pane that left of the current pane (-L for left), and the following lines work the same way.

this is only the tip of the iceberg with tmux. You can find out more about tmuxinator and see other config files with the links below.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s