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.

Similar Posts