Tmux and Vim, get marrieder. Or, Tmuxination.

As described in a post a few weeks back, a consistent and reliable development environment makes the job of a front-end developer so much easier. One of the tools that I've begun using to expedite the arrangement of Tmux panes and windows is a Ruby gem called Tmuxinator.

Tmuxinator

Tmuxinator allows one to run a single shell command which launches Tmux, and instantly runs all of the commands you might typically use in setting up your workspace. Things like mysql.server start, splitting panes and windows, starting irssi, etc… It’s super fun fun rad.

Installation is pretty easy, if you’re comfortable installing Ruby gems. I’ll assume you’ve already set up an environment using rbenv or rvm:

  $ gem install tmuxinator

Ta-da!

Per the github project page, be sure to specify a $SHELL variable and an $EDITOR variable in your respective .bash_profile or .zshrc.

With Tmuxinator, we can now create a persistent development environment by using a yml file, named for the environment. We can make this project specific, but I prefer to use a general development environment, as I work with many projects a day.

  $ tmuxinator new development

This command will create a yml file in ~/.tmuxinator called development.yml. Using this file, we can specify what panes and windows will open with Tmux, and what programs will launch therein. Below is the configuration I’m currently using. Nothing too fancy, but you’ll notice that I use “pre” to launch mysql.

  project_name: development project_root: ~/ pre: mysql.server start tabs:
    - edit: layout: 553c,178x51,0,0{116x51,0,0,61x51,117,0} panes:
          - vim
          - irssi
    - shell: layout:
    e062,178x51,0,0{89x51,0,0,88x51,90,0[88x25,90,0,88x25,90,26]} panes:
          - #empty
          - #empty
          - #empty
    - remote: layout: even-horizontal panes:
          - ssh me@myserver
          - #empty

There are 3 windows, and each window has a few panes that open when I launch tmux. The layout bit specifies how I would like those panes to be arranged, what size I’d like them to be, and what programs I would like them to run by default. A good question was asked, and then answered, at stackoverflow as to how one can figure out the pane layout. Basically, it consists of running tmux, arranging panes, and running :list-windows to see the layout one can feed tmuxinator.

Now, one only needs to run tmuxinator start development, and all panes and windows will start.