Powerline – Adds Statuslines and Prompts to Vim and Bash Shell

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

It enhances the appearance and functionality of the Vim editor by providing a customizable and informative status line at the bottom of the editor window, which includes current mode (e.g., normal, insert, visual), file name, path, line and column numbers, Git branch, virtual environment, and more.

Powerline Vim Statuslines
Powerline Vim Statuslines

Features

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

In this article, I will show you how to install Powerline and Powerline fonts and how to use Bash and Vim under RHEL-based and Debian-based distributions.

How to Install Powerline in Linux

Due to a naming conflict with some other unrelated projects, the 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 the pip tool under our Linux systems.

$ sudo apt install python3-pip         [On Debian, Ubuntu and Mint]
$ sudo yum install python3-pip         [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux]
$ sudo emerge -a dev-lang/pip          [On Gentoo Linux]
$ sudo apk add py3-pip                 [On Alpine Linux]
$ sudo pacman -S python-pip            [On Arch Linux]
$ sudo zypper install python3-pip      [On OpenSUSE]    

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

$ sudo apt install git    [On Debian, Ubuntu and Mint]
$ sudo yum install git         [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux]
$ sudo emerge -a git           [On Gentoo Linux]
$ sudo apk add git             [On Alpine Linux]
$ sudo pacman -S git           [On Arch Linux]
$ sudo zypper install git      [On OpenSUSE]    

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

$ pip install powerline-status

If you get the error message “externally-managed-environment“, which typically occurs in the context of Python virtual environments when using Powerline or related tools.

To fix this error, just delete the following file and run the pip install command again.

$ sudo rm -rf /usr/lib/python3.x/EXTERNALLY-MANAGED 

Alternatively, you can install Powerline by executing a command specific to your package manager as shown.

$ sudo apt install powerline         [On Debian, Ubuntu and Mint]
$ sudo yum install powerline         [On RHEL/CentOS/Fedora and Rocky/AlmaLinux]
$ sudo emerge -a sys-apps/powerline  [On Gentoo Linux]
$ sudo apk add powerline             [On Alpine Linux]
$ sudo pacman -S powerline           [On Arch Linux]
$ sudo zypper install powerline      [On OpenSUSE]    

How to Install Powerline Fonts in Linux

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

If you have installed Powerline through PIP, you can install the latest version of the symbol font and fontconfig file as shown.

$ wget https://github.com/powerline/powerline/raw/develop/font/PowerlineSymbols.otf
$ wget https://github.com/powerline/powerline/raw/develop/font/10-powerline-symbols.conf
$ sudo mv PowerlineSymbols.otf ~/.local/share/fonts/
$ sudo fc-cache -vf ~/.local/share/fonts/
$ sudo mv 10-powerline-symbols.conf ~/.config/fontconfig/conf.d/

If you have installed Powerline through the package manager, you can install the latest fonts by running:

$ sudo apt install fonts-powerline         [On Debian, Ubuntu and Mint]
$ sudo yum install powerline-fonts         [On RHEL/CentOS/Fedora and Rocky/AlmaLinux]
$ sudo emerge -a sys-apps/powerline-fonts  [On Gentoo Linux]
$ sudo apk add powerline-fonts             [On Alpine Linux]
$ sudo pacman -S powerline-fonts           [On Arch Linux]
$ sudo zypper install powerline-fonts      [On OpenSUSE]    

Enable Bash Color Prompts Using Powerline

If you have installed Powerline through PIP, you can enable it by bash shell and vim editor by adding the following line to the ~/.bashrc file as follows.

export TERM=”screen-256color” 

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

First, get the location of the installed powerline using the following command.

$ pip show powerline-status

Name: powerline-status
Version: 2.7
Summary: The ultimate statusline/prompt utility.
Home-page: https://github.com/powerline/powerline
Author: Kim Silkebaekken
Author-email: [email protected]
License: MIT
Location: /home/tecmint/.local/lib/python3.11/site-packages

Once you know the actual location of the 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
. /home/tecmint/.local/lib/python3.11/site-packages/powerline/bindings/bash/powerline.sh

If you have installed Powerline through the package manager, you can enable it by running:

$ source /usr/share/powerline/bindings/bash/powerline.sh

Now try to log out and log in back again, you will see the powerline statusline as shown below.

Bash Powerline Statuslines
Bash Powerline Statuslines

Try changing or switching to different directories and keep an 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 Vim Color Prompts with Powerline

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.

python3 from powerline.vim import setup as powerline_setup
python3 powerline_setup()
python3 del powerline_setup

set laststatus=2

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

Vim Powerline Statuslines
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.

Ravi Saive
I am an experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

44 thoughts on “Powerline – Adds Statuslines and Prompts to Vim and Bash Shell”

  1. Hey, thanks for the guide, it worked very well. I had 2 issues and would like to get cleared:

    1. for terminal, how do i put arrows at end of path instead of rectangular box?
    2. I use yakuake as terminal. powerline worked on it but for vim instead of arrows, weird symbols were shown. can you tell me how to fix that?

    Reply
  2. 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. ?

    Reply
  3. 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?

    Reply
  4. 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

    Reply
  5. 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. :)

    Reply
  6. 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.

    Reply
    • @Victor,

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

      # pip uninstall package-name
      
      Reply
  7. 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

    Reply
    • @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
      
      Reply
  8. 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.

    Reply
    • @Paulo,

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

      Reply
    • @Paulo,

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

      Reply
  9. Hello!! nice post, always work for me.
    How can I set the maxlength of the pwd to 1, eg:
    I want this:
    diego>..>Dir5
    instead of:
    diego>-…>Dir3>Dir4>Dir5>

    Reply
  10. Hey,

    I’ve got this to work, even with the fonts but the bash line doesn’t word wrap properly. it just starts over at the beginning of the line.

    Reply
  11. after going through this, I kept getting errors when running “vim”, “git status”, “screen” saying that terminal is not full functional and that screen-256color not defined.

    figured out mistake was in ~/.bashrc:

    while this tutorial had quotations around screen-256 like so:

    export TERM=”screen-256color”

    it should have been without quotations, like so:

    export TERM=screen-256color

    hope this saves someones time.

    Reply
  12. Followed every instructions step it doesn’t work. I get this output when opening a terminal:

    No command ‘powerline-deamon’ found, did you mean:
    Command ‘powerline-daemon’ from package ‘powerline’ (universe)
    powerline-deamon: command not found
    bash: /home/mcx/.local/lib/python2.7/site-packages/powerline/bindings/bash/../../../scripts/powerline-config: No such file or directory
    bash: /home/mcx/.local/lib/python2.7/site-packages/powerline/bindings/bash/../../../scripts/powerline-config: No such file or directory
    mcx@mcx:~$

    Reply
  13. I noticed little vertical lines on the right side of the statusline that seem misplaced. Any one agree? If so does anyone know how to fix it?

    Reply
  14. The documentation is off for EL7. The proper instructions are as follows:
    As root do:
    (coreutils is for printf for down below, should already be there, but thats why I am adding it explicitly here)
    1)yum install python-pip git coreutils
    2)pip install git+git://github.com/Lokaltog/powerline
    3)wget -o /usr/share/fonts https://github.com/powerline/powerline/raw/develop/font/PowerlineSymbols.otf
    4)wget -o /etc/fonts/conf.d/ https://github.com/powerline/powerline/raw/develop/font/10-powerline-symbols.conf
    5)fc-cache -vf /usr/share/fonts/

    On each user do the following:
    Do up bash
    6)printf “powerline-daemon -q%s\nPOWERLINE_BASH_CONTINUATION=1%s\nPOWERLINE_BASH_SELECT=1%s\n. /usr/lib/python2.7/site-packages/powerline/bindings/bash/powerline.sh” >> ~/.bashrc
    Do up vim
    7)printf “set rtp+=/usr/local/lib/python2.7/dist-packages/powerline/bindings/vim/%s\nset laststatus=2%s\nset t_Co=256” >> ~/.vimrc

    Reply
  15. Is it possible to force some kind of compatibility mode with SSH apps like putty? I’m getting squares where symbols should be.

    Reply
  16. I got it working in bash but when I open up vim, i get this message –

    E558: Terminal entry not found in terminfo
    ‘”screen-256color”’ not known. Available builtin terminals are:
    builtin_amiga
    builtin_beos-ansi
    builtin_ansi
    builtin_pcansi
    builtin_win32
    builtin_vt320
    builtin_vt52
    builtin_xterm
    builtin_iris-ansi
    builtin_debug
    builtin_dumb
    defaulting to ‘ansi’

    1

    Reply
  17. i have problem in this commad:

    pip show powerline-status

    Error command not found you have tu install show, when install show, now say you use –upgrade to upgrade, help

    Reply

Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.