Wednesday, June 26, 2019

Install Oh-my-zsh and powerline fonts on Ubuntu 18.04

I recently installed Ubuntu 18.04 on my X1 Carbon (1st Gen that sat under the bed for years), and I'm actually enjoying using this notebook again!

The first thing I did was install a few basics that included oh-my-zsh. I love the information that the prompt displays for your git repos. Shown below is oh-my-zsh using the agnoster theme. 

Oh-My-Zsh with Git Repo Status

However, if the powerline fonts aren't installed, then it doesn't look so great. The icons show up as boxes with X's in them. 

I didn't have the powerline fonts installed, so I searched for the correct way to install the fonts on Ubuntu and found that a bunch of people were having difficulties.

I ended up following the directions on the powerline font github repo's README, and it worked without too much effort, so I figured I would post all the steps I followed to get oh-my-zsh installed and configured the way I like it.

Oh-My-Zsh and Powerline Font Install

First, install oh-my-zsh.
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

After the install, you end up with a .zshrc file in your home directory. I updated the .zshrc file to use the agnoster theme instead of the default theme of robbyrussell. Just update the ZSH_THEME value.
ZSH_THEME="agnoster"

Second, install the powerline fonts so you can see the nice status icons for the current directory of your git repos. You can install the fonts this way:
sudo apt-get install fonts-powerline

Or by cloning the git repo and running their install script:
git clone https://github.com/powerline/fonts.git --depth=1
cd fonts
./install.sh
cd ..
rm -rf fonts

If after running those commands (which probably only needed to consist of the apt-get install), the prompt for zsh has not started showing the nice status icons and colorized branches, then you can update the fontconfig information by creating a file in this directory (create the directory if it doesn't exist):
~/.config/fontconfig/conf.d

Then copy this file to ~/.config/fontconfig/conf.d.

Followed by running the font config cache command, which will force the font config cache to be update (-f) and display status information (-v).
fc-cache -vf 

It was after I ran the fc-cache command that I noticed the terminal show the git repo status information with the branch and status icons. I used both the apt-get install fonts-powerline method, and the