Richard Hart

Head of Something @ Somewhere
Kent, UK

My Music
My Photos


Switching to tmux

Not being one to jump on bandwagons, I just had to try tmux after hearing so many people talk about it. tmux is a terminal multiplexer allowing you to run a number of terminals within a single screen as well as allowing you to detach and reattach to the same session as you please.

So what? I can just run multiple tabs and get the same effect!

Yes and no. I had been running multiple tabs, with vim in one window, a console session in another and tailing output in another, but the real revelation with tmux came when I tried out the tmuxinator gem. tmuxinator allows you to easily manage tmux sessions. With a simple yaml file you can create and start a tmux session with your editor, console and logging all setup, laid out and ready to go. This is incredibly useful with you work across multiple projects as quite frequently I would find myself in tab hell when having to switch from one project to another. Once you get past having more than four or five tabs open it become increasingly difficult to know which is which. tmux sessions mean I can keep everything related to a single “context” within one terminal session.

Getting up and running wasn’t 100% smooth sailing. Brian P. Hogan’s tmux: Productive Mouse-Free Development was invaluable. Even with less than a full days use, I’m pretty comfortable and have gotten over the initial slowdown that comes with switching to a new tool.

The only thing I miss is that I can no-longer use CMD-S for saving like in MacVim, but to be honest that’s a bad habit I need to break, as well as colour schemes aren’t quite as pretty in command line Vim compared to MacVim.

A few gotchas I encountered:

  • When using Vim and the Command-T plugin, up/down arrows wont work for selecting a file to open, you will have to use CTRL-J/K to move up and down and CTRL-C to close the pane.
  • When adding reattach-to-user-namespace to enable copy/paste to your tmux.conf, you must kill your tmux session for the change to take place, it’s not enough to just quit and restart tmux.
  • If you’re using rvm, opening a new pane/window into a directory with an .rvmrc wont properly load in the selected ruby. If you’re on bash then adding “cmd .” to your .bashrc should work (I haven’t tried it), but for me I had to add “source .rvmrc” to my .zshrc for it load in properly.