Setting up Powerline for Vim and Tmux

UPDATE: As promised, I’ve added a post about how I configured my tmux to emulate some of the features of powerline.  You can read it here.

I spend almost all of my time on the command line and I use Tmux and Vim obsessively.  Like a lot of people, I want my environment to be pleasing, so I was excited when I found out about Powerline, a status line / prompt utility that works with bash prompts, Vim, Tmux and a whole slew of other tools.pl-mode-insert

My first impression is that Powerline is just really cool looking.  It’s nice to have something that lets you simply customize your tools in a simple way without having to dig deep into each individual tool.  Unfortunately, it has some big shoes to fill and it doesn’t quite make it all the way.

First, the documentation makes a few assumptions, that really threw me for a loop.  Installation is very simple using python pip.  All you have to do is:

pip install --user git+git://github.com/Lokaltog/powerline

OK, that’s all well and good, but now you have to do some magic with your fonts.  I’ll be honest, I’m not a front end kind of guy, and I don’t really know why this needs to be done, but OK, I can understand it…  This is a display tool, and you have to make sure you have the right fonts.  The instructions are located at: https://powerline.readthedocs.org/en/latest/installation/linux.html#font-installation, but basically you have to download some specific fonts, and configure X to use those fonts.  Fairly straight forward.

Now, here’s where I got lost for a while.  The docs say:

If installed using pip just use

python from powerline.vim import setup as powerline_setup
python powerline_setup()
python del powerline_setup

OK, but use them how?  At first I thought I needed to run those from the command line, but that didn’t do anything.  Then I thought maybe I need to go into interactive python and run those commands, but that threw about 150 errors.  Finally, after reading through some of the Vim Python integration docs, I figured out that you just put those lines in your .vimrc…   Still nothing happened.

So, there’s one more line in the docs, that talks about installing with Vundle or pathogen, which I didn’t do… So, I thought I could ignore that section.  Turns out, I couldn’t.  So, I had to also add this to mmy .vimrc:

set rtp+={repository_root}/powerline/bindings/vim
Vim Powerline in Normal Mode

Vim Powerline in Normal mode

 

Finally, I had a cool Powerline statusline in Vim.  Now to get it set up for my bash prompt and Tmux.  The bash prompt was easy, just had to add this to my .bashrc:

. {repository_root}/powerline/bindings/bash/powerline.sh
Powerline default bash prompt.

Powerline’s default bash prompt.

and I thought Tmux was going to be a breeze as well.  You just have to add a similar line to tmux.conf:

source '{repository_root}/powerline/bindings/tmux/powerline.conf'

However, it turns out that there are all kinds of problems with Tmux.  I could never actually get the right side of the status line to show up, and if I was running tmux with a Powerline, then it screwed up the colors in my Vim Powerline.  Really annoying.  So, basically after all that work, I’m ripping the whole damn thing out.  The developer seems very responsive, and I realize that it’s difficult trying to support all the different variations of operating systems, terminals, language encodings and so forth, but if I’m going to have to do a lot of customization anyway, then why do I want to add a layer of extra configuration.  I’ll just tweak my tmux config directly.  And I found an excellent Vim plugin that does exactly what I’m looking for directly in vim.  It’s vim-airline, and it’s vimscript only.   Minimal config, minimal dependencies, and it just works.

vim-airline, a very nice lightweight status line utility for vim.

vim-airline, a very nice lightweight status line utility for vim.

So, basically, I’m going with vim-airline for Vim, and I’m going to try and get something nice going in Tmux just using configuration.