Tmuxline and Promptline

· geek · software ·

tmuxline and promptline

Sometimes, tinkering begets more tinkering. Writing about my most recent tinkering session in Tinkering with Vim, I found myself wanting to tweak one or two things a little further. This was partly because I came across a couple of very interesting Vim plugins (tmuxline.vim and promptline.vim) that — oddly — act to alter the appearance and function of the tmux status bar and the shell prompt respectively.

While I liked my previous powerline setup, a few things niggled me a little about it:

  1. It was a little CPU intensive on older machines. This is partly my fault because I was using a few features like checking the weather, displaying the current track, mailbox count and so on. Even so, you want your terminal to be snappy, even if nothing else is.
  2. The setup was rather complex, as I found when someone asked me how I got powerline to look the way I did, and I had some trouble tracking down all the relevant settings files.
  3. The colour scheme didn’t match the nice Solarized one I had for Vim. I know: “Mercy me! My terminal colour schemes don’t match, what will the neighbours say?”

tmuxline.vim tackles point 3 by setting the tmux status line to the same colour scheme that you are using with airline within Vim (it’s also compatible with lightline if you use that). You can also configure the tmux status line more easily with ‘segments’ which get automatically styled, which helps a lot with point 2. The odd thing is that you do this within Vim. You can either use the included themes and presets (layouts), or you can use simple configuration within your .vimrc to set the theme and/or the layout to your preference. You then run a command (again within Vim) that generates a file with the code tmux needs to configure itself. All you need to do then is source the generated file in your .tmux.conf to have everything set up the way you want it even before you have launched Vim. It feels a little odd doing it this way, but in practice, it works well and keeps the configuration neat and easy to modify. I’m really happy with my new status bar, which gives me all the information I need without being over the top, and is very fast and light, solving point 1.

promptline.vim applies the same principle to constructing a shell prompt. You set it up the same way, with optional configuration in your .vimrc, use the command within Vim to generate the code in a file, then source that file in your .bashrc or .zshrc. What I’ve done is move some of the git branch and status info from the tmux status bar to my promptline. My prompt shows the truncated path, and if in a git repository, the branch, current sha, and on the right side, symbols show the status (uncommitted changes, commited changes to push etc.), all in a style matching the Vim status line and the tmux status bar. In addition, if I’m in a Python virtualenv, it gives the name of the virtualenv.

I’ve updated the gist with my new config if you’re curious to try it out.