Setting up powerline for iTerm2

Some years ago, one of my co-workers pointed me to powerline.
Among other fancy features, it displays your current location in the directory structure. Something like this -
so you do not have to frequently do a pwd to figure out where you are.

This post outlines what you would need to do to set up powerline.

Install pip if you have not, by doing:

sudo easy_install pip

Install powerline by doing:

pip install --user powerline-status

This should set up powerline. For me (OS: High Sierra), the path was $HOME/Library/Python/2.7/lib/python/site-packages/powerline

Then add the following lines to your .bash_profile to source powerline.sh:

#!/bin/bash
# Powerline set-up

# The following line is required because 
# `powerline.sh` is unable to find 
# `scripts/powerline-config` without this 
# in the `PATH`.

PATH="$HOME/Library/Python/2.7/bin:$PATH"

# Source the script
. $HOME/Library/Python/2.7/lib/python/site-packages/powerline/bindings/bash/powerline.sh

Install fonts by following instructions here. I did this:

#!/bin/bash
git clone https://github.com/powerline/fonts
cd fonts

# Install fonts
./install.sh

# Clean up
cd ..
rm -rf fonts

Then go to iTerm2 > Preferences > Profiles > Text and set up powerline fonts for ASCII and non-ASCII fonts like so:

Troubleshooting

  • My powerline status shows question mark or other special characters instead of arrows. What's wrong?

This happens if you have not selected a powerline font for non-ASCII characters.

  • When I bring up my terminal, I get an error message like this:
-bash: <some long path>/scripts/powerline-config: No such file or directory

This happens if the powerline installation is not in your PATH. Figure out where you installed powerline. In my case it is $HOME/Library/Python/2.7/bin. Including this in the PATH allows the script to be sourced.

More power to your command line!

Chaitra Suresh

Chaitra Suresh

Mom, Engineering Manager, Cook, Musician
California