Powerline on Linux: An Integration Guide

Render clean status lines and prompts in Vim, Bash, i3 and tmux


System Dependencies

$ sudo pacman -S python      # Arch
$ sudo apt install python # Debian and Ubuntu
$ sudo dnf install python # Fedora and CentOS
$ sudo pacman -S git         # Arch
$ sudo apt install git # Debian and Ubuntu
$ sudo dnf install git # Fedora and CentOS


Installing Pip

$ cd ~/Downloads
$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
$ python3.8 get-pip.py# Output
Successfully installed pip-20.2.4 setuptools-50.3.2 wheel-0.35.1
$ sudo find / -name pip# Output
$ echo $PATH
$ vim ~/.bashrc
# In bash.rc
export PATH="~/.local/bin:$PATH"
# Provide an absolute path
alias pip=”/home/dane/.local/bin/pip”
$ source ~/.bashrc
$ pip --version
# Output
pip 20.2.4 from /home/dane/.local/lib/python3.8/site-packages/pip (python 3.8)
# Display pip help
$ pip -h

Installing Powerline

$ pip install powerline-status
$ pip show powerline-status# Output
Location: /home/dane/.local/lib/python3.8/site-packages
$ pip uninstall powerline-status

Python Packages

$ pip install psutil i3ipc# Installs to:
# ~/.local/lib/python3.8/site-packages/psutil
# ~/.local/lib/python3.8/site-packages/i3ipc

Font Installation

$ git clone https://github.com/powerline/fonts.git --depth=1 
$ cd powerline-fonts
$ ./install.sh
# Output
Copying fonts...
Resetting font cache, this may take a moment...
Powerline fonts installed to /home/dane/.local/share/fonts
# List fonts directory to confirm the copy was successful
$ ls ~/.local/share/fonts
$ yay -S font-manager              # Arch
$ sudo apt install font-manager # Debian and Ubuntu
$ sudo dnf install font-manager # Fedora
# Run
$ font-manager
Previewing powerline fonts with the Font Manager application.

Using Powerline with Vim

$ vim — version | grep +python# Output
+python/dyn +python3/dyn
set laststatus=2           " Always display the status bar
set powerline_cmd="py3" " Tell powerline to use Python 3
python3 from powerline.vim import setup as powerline_setup
python3 powerline_setup()
python3 del powerline_setup
The Vim status line being rendered with powerline.

Using Powerline with Bash

Modifying .bashrc

# Run powerline daemon
# To locate this file, run: sudo find / -name powerline-deamon

/home/dane/.local/bin/powerline-daemon -q
# Cache powerline location
# To locate this directory, run: pip show powerline-status

export POWERLINE_LOCATION="/home/dane/.local/lib/python3.8/site-packages/powerline"
# Set up powerline environment
export POWERLINE_CONFIG_COMMAND=powerline-config
# Invoke binding script
. "$POWERLINE_LOCATION/bindings/bash/powerline.sh"
# Kill the powerline daemon process
$ powerline-daemon -k
# Start the powerline daemon process quietly
$ powerline-daemon -q
# in .bashrc
alias pd=”powerline-daemon -k && powerline-daemon -q”
# Refresh configuration on the command line
$ source ~/.bashrc
Restarting the powerline daemon with an alias.

Setting Up a Configuration Directory

$ mkdir ~/.config/powerline
$ cp -fr {powerline_location}/config_files ~/.config/powerline

The Configuration Directory Structure

- powerline/
- config.json # Main configuration
- colors.json # Colors and gradient definitions
- colorschemes/ # Directory for all color schemes
- default.json
- <extension>/
- <scheme_name>.json
- themes/ # Directory for all themes
- <top_level>.json
- <extension>/
- <theme_name>.json

Creating a Theme for the Bash Prompt

"function": "powerline.segments.module.segment_name"
"args": {
"arg1": "val1",
"arg2": "val2", ...
"function": "powerline.segments.common.env.cwd",
"args": {
"ellipsis": "..", # String to use for omitted directories
"dir_shorten_len": 20, # Max directory character length
"dir_limit_depth": 2 # Max directory depth to render
"after": " ", # String to display after the output
"priority": 20 # Give a high rendering priority
The bash theme configuration file.
The segments used for our custom Bash prompt.
"shell": {
"colorscheme": "default",
"theme": "default_leftonly",
"local_themes": {
"continuation": "continuation",
"select": "select"

Creating a Color Scheme for the Bash Prompt

“teal”: 6,
“navyblue”: 17,
“darkblue2”: 18,
“slateblue”: 61,
“purpleturquoise”: 66,
“steelblue”: 67,
“gray01”: 234,
$ cd ~/.config/powerline/colorschemes
$ mkdir shell && cd shell
$ touch teal_dark.json
"group_name": { "fg": "color", "bg": "color", 
"attrs": ["bold", "italic", "underline"] }
The color scheme configuration file for the Bash prompt.
"shell": {
"colorscheme": "teal_dark",
"theme": "default_leftonly",
"local_themes": {
"continuation": "continuation",
"select": "select"
Our configured Bash prompt rendered with powerline.

Using Powerline with i3

bar {
status_command python3 {powerline_root}/powerline/bindings
font pango:Hacker 11
The i3 bar rendered with the default theme and color scheme configurations applied.

Installing a Powerline Extension for Memory Segments

pip install powerline-mem-segment

Creating a Theme for the i3 Bar

The theme configuration file for the i3 bar.
The segments used for our custom i3 bar.

Creating a Color Scheme for the i3 Bar

$ cd ~/.config/powerline/colorschemes
$ mkdir wm && cd wm
$ touch i3_dark.json
The color scheme configuration file for the i3 bar.
"wm": {
"colorscheme": "i3_dark",
"theme": "default",
"update_interval": 2
Our configured i3 bar without the external IP address segment.

Using Powerline with tmux

# Ensure the powerline daemon is running
run-shell "powerline-daemon -q"
# Invoke the tmux powerline binding
source "{powerline_root}/bindings/tmux/powerline.conf"
$ tmux new-session
Powerline rendering both the tmux status line and Bash prompt.

In Conclusion

MSc. Programmer and fan of open source software.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store