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.
- 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 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
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 (18.104.22.168-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]
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
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
# 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.
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.
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
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:
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.
44 thoughts on “Powerline – Adds Powerful Statuslines and Prompts to Vim Editor and Bash Terminal”
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. ?
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?
You need to add the powerline configuration to your user
~/.bashrcfile to keep it permanent..
Indeed, it works now! Thanks a lot for the help :D
I had same problem, can you send me the powerline config to my email : [email protected]
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
Thanks for sharing, yes you correct python-setuptools package needs to install Powerline…
happy to help.. btw how can i get the arrows as seen on fedora magazine..
No idea, how the arrows appear, I think we should tweak some settings in powerline configuration files.
Ok.. It looks nice as it is.. It fulfills it’s purpose.. The arrows were an added plus
Yes, those arrows were additional features to powerline, you can get them, but you need to play with configuration..
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. :)
Thanks for sharing the tip, hope it will help others…
After installing powerline, my vim color scheme is lost. How can I get back to original color scheme?
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.
Thanks for sharing the tip with us, hope it will help other users..
Possible to provide guide to uninstall Powerline too? Its giving issue.
To uninstall packages installed using pip, just type following command to remove powerline from the system.
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
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:
You will see something like:
Now add the following line to your .bashrc file as shown:
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.
I just installed the powerline for testing purpose only, yes it is good, but I prefer vim with plain text…:)
Ravi can you show me how as was your complete vimrc.? I am Elementary OS user.
Sorry, you’re too late actually I removed powerline from my laptop, but could you tell me what exactly you looking for?