Setting up Powerline-shell

Posted by Michael Osburn on Sat 25 March 2017

For the last few months I have been using powerline-shell on my macbook at work. I started using this after a failed experiment with ZSH not agreeing with me and I really liked the look of what I have seen on other peoples systems but did not want to deal with ZSH just to have a nice terminal. After working with a few members of my team to get this setup, I have decided to just write it down and point people here.

# Required Repositories First and foremost, you need to clone a few repositories in order to get this to work. .. code-block:: bash

mkdir ~/git_repos

cd ~/git_repos

git clone https://github.com/milkbikis/powerline-shell

git clone https://github.com/powerline/fonts.git

Once these are done you need to install the powerline fonts package. .. code-block:: bash

cd powerline-fonts

./install.sh

Next, go into your terminal configuration and change the font to a powerline font. In iTerm2, the font change is for 'Non-ASCII font' as shown below. [image-iterm-font]

Once this is done, go into powerline-shell's repo and run the installer, followed by linking it to ~/bin.

cd ~/git_repos/powerline-shell/

./install.py

ln -s ~/git_repos/powerline-shell/powerline-shell.py> ~/bin/powerline-shell.py

I link this file to bin so that I can keep all my executables in one area of my home directory and not all over the place.

Finally, add the following to ~/.profile

function _update_ps1() {
    PS1="$(~/bin/powerline-shell.py $? 2> /dev/null)"
}

if [ "$TERM" != "linux" ]; then
    PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND
fi

Once this is done, resource your profile.

source ~/.profile