Powerline – Adds Powerful Statuslines and Prompts to Vim Editor and Bash Terminal

Powerline is a great statusline plugin for Vim editor, which is developed in Python and provides statuslines and prompts for many other applications such as bash, zsh, tmux and many more.

Install Powerline Statuslines in Linux

Add Power to Linux Terminal with Powerline Tool

Features

  1. It is written in Python, which makes it extensible and feature rich.
  2. Stable and testable code base, which works well with Python 2.6+ and Python 3.
  3. It also supports prompts and statuslines in several Linux utilities and tools.
  4. It has configurations and decorator colors developed using JSON.
  5. Fast and lightweight, with daemon support, which provides even more better performance.

Powerline Screenshots

Powerline Vim Statuslines

Powerline Vim Statuslines

In this article, I will show you how to install Powerline and Powerline fonts and how to use with Bash and Vim under RedHat and Debian based systems.

Step 1: Installing Generic Requirements for Powerline

Due to a naming conflict with some other unrelated projects, powerline program is available on PyPI (Python Package Index) under the package name as powerline-status.

To install packages from PyPI, we need a ‘pip‘ (package management tool for installing Python packages). So, let’s first install pip tool under our Linux systems.

Install Pip on Debian, Ubuntu and Linux Mint

# apt-get install python-pip
Sample Output
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Recommended packages:
  python-dev-all python-wheel
The following NEW packages will be installed:
  python-pip
0 upgraded, 1 newly installed, 0 to remove and 533 not upgraded.
Need to get 97.2 kB of archives.
After this operation, 477 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ trusty-updates/universe python-pip all 1.5.4-1ubuntu3 [97.2 kB]
Fetched 97.2 kB in 1s (73.0 kB/s)     
Selecting previously unselected package python-pip.
(Reading database ... 216258 files and directories currently installed.)
Preparing to unpack .../python-pip_1.5.4-1ubuntu3_all.deb ...
Unpacking python-pip (1.5.4-1ubuntu3) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up python-pip (1.5.4-1ubuntu3) ...

Install Pip on CentOS, RHEL and Fedora

Under Fedora-based systems, you need to first enable epel-repository and then install pip package as shown.

# yum install python-pip          
# dnf install python-pip                     [On Fedora 22+ versions]           
Sample Output
Installing:
 python-pip          noarch          7.1.0-1.el7             epel          1.5 M

Transaction Summary
=================================================================================
Install  1 Package

Total download size: 1.5 M
Installed size: 6.6 M
Is this ok [y/d/N]: y
Downloading packages:
python-pip-7.1.0-1.el7.noarch.rpm                         | 1.5 MB  00:00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python-pip-7.1.0-1.el7.noarch                                 1/1 
  Verifying  : python-pip-7.1.0-1.el7.noarch                                 1/1 

Installed:
  python-pip.noarch 0:7.1.0-1.el7                                                

Complete!

Step 2: Installing Powerline Tool in Linux

Now it’s’ time to install Powerline latest development version from the Git repository. For this, your system must have git package installed in order to fetch the packages from Git.

# apt-get install git
# yum install git
# dnf install git

Next you can install Powerline with the help of pip command as shown.

# pip install git+git://github.com/Lokaltog/powerline
Sample Output
 Cloning git://github.com/Lokaltog/powerline to /tmp/pip-WAlznH-build
  Running setup.py (path:/tmp/pip-WAlznH-build/setup.py) egg_info for package from git+git://github.com/Lokaltog/powerline
    
    warning: no previously-included files matching '*.pyc' found under directory 'powerline/bindings'
    warning: no previously-included files matching '*.pyo' found under directory 'powerline/bindings'
Installing collected packages: powerline-status
  Found existing installation: powerline-status 2.2
    Uninstalling powerline-status:
      Successfully uninstalled powerline-status
  Running setup.py install for powerline-status
    
    warning: no previously-included files matching '*.pyc' found under directory 'powerline/bindings'
    warning: no previously-included files matching '*.pyo' found under directory 'powerline/bindings'
    changing mode of build/scripts-2.7/powerline-lint from 644 to 755
    changing mode of build/scripts-2.7/powerline-daemon from 644 to 755
    changing mode of build/scripts-2.7/powerline-render from 644 to 755
    changing mode of build/scripts-2.7/powerline-config from 644 to 755
    changing mode of /usr/local/bin/powerline-config to 755
    changing mode of /usr/local/bin/powerline-lint to 755
    changing mode of /usr/local/bin/powerline-render to 755
    changing mode of /usr/local/bin/powerline-daemon to 755
Successfully installed powerline-status
Cleaning up...

Step 3: Installing Powerline Fonts in Linux

Powerline uses special glyphs to show special arrow effect and symbols for developers. For this, you must have a symbol font or a patched font installed on your systems.

Download the most recent version of the symbol font and fontconfig configuration file using following wget command.

# wget https://github.com/powerline/powerline/raw/develop/font/PowerlineSymbols.otf
# wget https://github.com/powerline/powerline/raw/develop/font/10-powerline-symbols.conf

Then you need to move the font to your fonts directory, /usr/share/fonts/ or /usr/local/share/fonts as follows or you can get the valid font paths by using command xset q.

# mv PowerlineSymbols.otf /usr/share/fonts/

Next, you need to update your system’s font cache as follows.

# fc-cache -vf /usr/share/fonts/

Now install the fontconfig file.

# mv 10-powerline-symbols.conf /etc/fonts/conf.d/

Note: If custom symbols doesn’t appear, then try to close all terminal sessions and restart X window for the changes to take effect.

Step 4: Setting Powerline for Bash Shell and Vim Statuslines

In this section we shall look at configuring Powerline for bash shell and vim editor. First make your terminal to support 256color by adding the following line to ~/.bashrc file as follows.

export TERM=”screen-256color” 

Enable Powerline on Bash Shell

To enable Powerline in bash shell by default, you need to add the following snippet to your ~/.bashrc file.

First get the location of installed powerline using following command.

# pip show powerline-status

Name: powerline-status
Version: 2.2.dev9999-git.aa33599e3fb363ab7f2744ce95b7c6465eef7f08
Location: /usr/local/lib/python2.7/dist-packages
Requires: 

Once you know the actual location of powerline, make sure to replace the location in the below line as per your system suggested.

powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
. /usr/local/lib/python2.7/dist-packages/powerline/bindings/bash/powerline.sh

Now try to logout and login back again, you will see powerline statuesline as shown below.

Bash Powerline Statuslines

Try changing or switching to different directories and keep a eye on “breadcrumb” prompt changes to show your current location.

You will also be able to watch pending background jobs and if powerline is installed on a remote Linux machine, you can notice that the prompt adds the hostname when you connect via SSH.

Enable Powerline for Vim

If vim is your favorite editor, luckily there is a powerful plugin for vim, too. To enable this plugin, add these lines to ~/.vimrc file.

set  rtp+=/usr/local/lib/python2.7/dist-packages/powerline/bindings/vim/
set laststatus=2
set t_Co=256

Now you can launch vim and see a spiffy new status line:

Vim Powerline Statuslines

Summary

Powerline helps to set colorful and beautiful statuslines and prompts in several applications, good for coding environments. I hope you find this guide helpful and remember to post a comment if you need any help or have additional ideas.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Ravi Saive

I am Ravi Saive, creator of TecMint. A Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux. Follow Me: Twitter, Facebook and Google+

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

44 Responses

  1. Nikhil Parmar says:

    That works great !! Only one things thats annoying is , if the path to the directory is very long, it displays a very long path on the shell prompt, sometimes it appears on the next line too. Can it be restricted to the Just the Current folder as of that like in Bash. ?

  2. Ken Chan says:

    Hi, I am having a problem, when I complete all the steps, it works great. However, as soon as I close and reopen terminal, it gets back to the default look. Can you guys please help me?

  3. The Linux Evangelist says:

    You forgot to mention to install setuptools using

    sudo apt-get install python-setuptools
    sudo yum install python-setuptools
    sudo dnf install python-setuptools

    Without setuptools, you wont be able to install powerline

  4. Hein Htet Aung says:

    Ok, fixed it. The problem is I don’t have .vimrc. So, I created .vimrc and added those lines. And then, my vim editor color scheme is lost. Delete .vimrc and it’s back again. So, I add the lines for .vimrc to “/etc/vim/vimrc”. And everything is fine. :)

  5. Hein Htet Aung says:

    After installing powerline, my vim color scheme is lost. How can I get back to original color scheme?

  6. Lenny says:

    I had a problem with vim displaying UTF-8 placeholder characters in odd places, and the HOME and END keys misbehaving (printing ‘H’, ‘F’, and making newlines). This was fixed by specifying “set term=xterm-256color” in .vimrc to override “screen-256color”. Using Ubuntu / Terminator & Guake / bash.

    I also played with setting xterm-256color in .bashrc, and didn’t see any issues.

  7. Victor Ong says:

    hi Ravi,

    Possible to provide guide to uninstall Powerline too? Its giving issue.

    • Ravi Saive says:

      @Victor,

      To uninstall packages installed using pip, just type following command to remove powerline from the system.

      # pip uninstall package-name
      
  8. Omar says:

    i have a probleme……when a finish the tutorial and i exit and start the terminal
    i see this message : bash: ./usr/local/lib/python3.4/dist-packages/powerline/bindings/bash/powerline.sh: No such file or directory

    • Ravi Saive says:

      @Omar,

      If you’ve installed powerline using pip you must add the path variable to .bashrc file where pip puts scripts to $PATH.

      First make sure to find out your powerline location using:

      # pip show powerline-status
      

      You will see something like:

      Location: /usr/local/lib/python2.7/dist-packages
      

      Now add the following line to your .bashrc file as shown:

      /usr/local/lib/python2.7/dist-packages/powerline/bindings/bash/powerline.sh
      
  9. Paulo says:

    No problems. But why you deleted powerline? It’s so nice with vim! Did you found something better? Anyway, i just want change the color highlight red that is too heavy. I can’t see the pieces of code with red color. Thanks.

    • Ravi Saive says:

      @Paulo,

      I just installed the powerline for testing purpose only, yes it is good, but I prefer vim with plain text…:)

  10. Paulo says:

    Ravi can you show me how as was your complete vimrc.? I am Elementary OS user.

    • Ravi Saive says:

      @Paulo,

      Sorry, you’re too late actually I removed powerline from my laptop, but could you tell me what exactly you looking for?

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.