Tuesday 8 May 2012

Throwing tmux Into the Mix

I like a clean desktop and I like to have as few windows open as possible. Opening, closing, minimising and having to move windows around to much annoys me. As part of my [vimquest][0] I’ve been reading lots of blogs and a piece of kit that kept popping up was [tmux][2]. Tmux (Terminal Multiplexerm, see what they’re doing there? that’s clever stuff.) It’s described as …

tmux is a terminal multiplexer: it enables a number of terminals (or windows), each running a separate program, to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached.

What that means is that I can create a number of terminal sessions, close the terminal windows and come back to them later on – exactly as I left them. Music to my ears because when I’m working in VIM I’ve also normally got the following processes running in their own terminal windows –

  • python manage.py runserver
  • python manage.py shell
  • vim .
  • random stuff

So I’ll be continuing my [vimquest][0] using tmux to manage my windows and enjoying the added bonus of being able to close terminal ( I’ve recently switched to using iTerm2, but I’ve been using terminal for so long that I keep using referring to the terminal) windows and come back to them exactly as they were.

Installation and Configuration

I used brew to install tmux so I didn’t have to faff around with compiling from source. It was as easy as –

 brew install tmux 

After installation I started up a tmux session and in that session opened an instance of VIM. I noticed that the syntax highlighting in VIM had disappeared. I found the answer in this blog post on [vim and tmux][1], but in short I needed to export a variable in my ~/.bash_login' <div class="highlight bash"> <pre> alias tmux="TERM=screen-256color-bce tmux" </pre> </div> and then set a line in~/.tmux.conf`

 set -g default-terminal “screen-256color” 
As I learned from my first few days of [vimquest][0] there is no learning experience quite like doing, so I’m sure that in the days to come I’ll be posting as much about tmux as I am about vim. Now time to get coding, I’ve got 40 mins before I need to be at work. [0]: /blog/tags/vimquest/ [1]: http://rhnh.net/2011/08/20/vim-and-tmux-on-osx [2]: http://tmux.sourceforge.net/