Powerline-Inspired OMZSH Themes


Update: Please see the newest post for Powerlevel9k, here.


About two years ago, I made the 'hackersaurus' theme for oh-my-zsh. It still suits my purposes very well - it looks decent, and provides exactly what I need / want. That said, I recently discovered the agnoster theme, which looks amazing thanks to the use of Powerline fonts.

The agnoster theme lacks a few things I really like, though. The big items are the system time, command history number, and display of return code (it does show failure status, but not the code itself).

I built on top of agnoster, and am happy to introduce the powerlevel9k theme. Most of this theme is really the agnoster theme. All I added are the items on the right-side prompt. Here is what it looks like:

New features that didn't exist in the HokieTux theme (these are all carried-over from agnoster):
1. Looking even more badass.
2. Displays a 'gear' if there is a background job.
3. If you aren't your 'normal' user, it conditionally displays the user@host string.

There is one major downside to this theme compared to my old HokieTux theme, which is that it requires the installation of Powerline fonts. This can be a pain. But, it's totally worth it because it just looks awesome.

[Note: In the first version of this post I commented that the powerlevel9k theme provided less information about git repos due to the vcs_info module. This was a bug in my code and has since been fixed. See the update to this post for more information.]

The new theme also uses the vcs_info module, which is signficantly faster than the code in the hokietux theme.

Where to Get It

I'm maintaining powerlevel9k in it's own repo, which you can find on Github. Unfortunately, Oh-My-Zsh doesn't like subdirectories in the /themes directory, so you can't make it a 'git submodule'. You'll need to either copy it into your .oh-my-zsh/themes folder or make a symlink to it.

Other Powerline-Inspired ZSH Themes

Before making this, I found a project by someone else to do something similar - marick2000's zsh2000 theme. I gave it a shot, but most of it didn't work, unfortunately.

After finishing my theme, I discovered jeremyFreeAgent's oh-my-zsh-powerline theme, which actually does do everything my theme does. It also uses the OMZSH git plugin, so it displays more information (and is a bit slower). I like where my theme is for now, though, so I'm going to stick with it, but jeremyFreeAgent's theme also looks really great.

Installing Powerline Fonts for ZSH

I had the Powerline fonts installed for Vim, and those were working perfectly, so I was really surprised when ZSH couldn't seem to find / use the fonts. For Vim, I had installed them using the 'Patched Font Installation' method.

To get Powerline fonts working with ZSH, I had to use the fontconfig installation method. Without it, ZSH just couldn't find them. It doesn't hurt to do both methods, so that's what I recommend if you aren't sure. You can find the Powerline Font Installation Instructions here.

Troubleshooting Spaces in Powerline Separators

The other major issue while trying to get ZSH up and running with Powerline fonts - there seemed to be a space between separator characters. Here is a picture:

Notice that extra spacing? Super annoying. I was able to fix this by changing the default font in my terminal emulator to a Powerline font. In gnome-terminal and terminator (the two emulators I generally use), that setting is in the profile preferences.