tmux + tmuxinator + vim

I’ve been messing with Rails/Phoenix lately and feel like I’ve upped my terminal game significantly in the process. I’m an iOS engineer by day so I’m used to doing most of my work in Xcode. For web dev, my workflow revolves around tmux and vim - here’s a little bit about how I’m using them


Tmux is a terminal multiplexer that makes working with multiple programs in a single terminal session much more convenient. What I’ve found useful is using one window split into a few panes for things I just want to keep an eye on - Guard running tests/my server/a tail of the log for example. Then I’ll use another window for writing code, and another window for issuing miscellaneous commands.

Here’s what my ~/.tmux.conf looks like:

# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix

# Improve colors
set -g default-terminal 'screen-256color'

# vim style pane navigation
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"
unbind %

So I have ctrl-b is remapped to ctrl-a, I’m using vim-like shortcuts for pane navigation, and I can split panes with | and -, all of which make navigating tmux feel much more intuitive. I also remapped ctrl to capslock, so using the prefix then running a command feels much easier to type.

Here’s a few useful aliases in my ./.zshrc

alias tml="tmux list-sessions"
alias tma="tmux -2 attach -t $1"
alias tmk="tmux kill-session -t $1"
alias tmn="tmux new-session -t $1"
alias tmd="tmux detach"

I can boot up a tmux session with tmn blog, detach with tmd, and reattach with tma blog


tmuxinator is a tool to manage tmux sessions and their configurations. When I’m working on my blog or a project in the terminal, I have a certain set up for each. tmuxinator lets me quickly fire up a tmux session with all the windows/panes I need to start working.

Here’s my tmux for this website

name: blog
root: ~/Developer/

# Specifies (by name or index) which window will be selected on project startup. If not set, the first window is used.
startup_window: editor

  - logs: jekyll s
  - editor: vim 

editor is set to vim in my zshrc.

Here’s a slightly more complex one for a Rails project

name: my project
root: ~/Developer/project

# Specifies (by name or index) which window will be selected on project startup. If not set, the first window is used.
# startup_window: editor       

  - editor: vim                
  - shell: 
    - gco master               
    - ggpull                   
  - logs:
    layout: main-horizontal  
        - guard                
        - rails s              
        - tail -f log/development.log


I’ve known the basics of vim for a while. But until recently, never tried to use it as an IDE. I’m still no vim-expert by any stretch of the imagination, but the following things really boosted my productivity.

  1. Understanding how to tabs and buffers to work with multiple files
  2. Using NERDTree to quickly navigate my project directory. Before knowing how to work with multiple files, I’d always just clumsily exit vim, and open a new file.
  3. YouCompleteMe for autocompletion

Some other useful plugins:

Plugin 'VundleVim/Vundle.vim'
Plugin 'plasticboy/vim-markdown' 
Plugin 'tpope/vim-fugitive'
Plugin 'slim-template/vim-slim.git'
Bundle 'powerline/powerline', {'rtp': 'powerline/bindings/vim/'}
Plugin 'tpope/vim-rails'
Plugin 'ctrlpvim/ctrlp.vim'

I’m realizing vim is basically a roll-your-own IDE. Most all of the features you could want from an IDE are available as plugins, it just takes some time to get vim configured in a way that makes you comfortable.