Introduction

I am currently using a Windows 10 laptop as my main OS. IMHO Microsoft has really turned it around as a company in recent years and I no longer think of them as M$ Virus Corp!! I still live in a terminal session for a lot of my day and I am not ready give up on Bash just yet. The ability to run Bash on Windows was one of the reasons I was willing to move back to Windows as my primary laptop OS.

In this post I will run through setting up the Powerline status plugin for Bash on Windows. This post assumes you already have Ubuntu for Windows 10 app installed. For instruction on how to do that check out the documentation here.

The following software versions were used / installed in this post.

  • Microsoft Windows 10 - 1809
  • Ubuntu for Windows - 1804
  • Powerline - 2.7

Update Ubuntu

If you have just installed the Ubuntu app, perform an update.

cmd

sudo apt update -y && sudo apt upgrade -y
            

Dependencies

Powerline requires patched fonts to correctly display icons, symbols and nice text.

  • Download the patched font from here
  • Extract the files and browse to the extracted directory
  • Find a file named install.ps1
  • Run the file in Powershell to install the fonts into the system

Install and update Python PIP

cmd

sudo apt install -y python3-pip

sudo pip3 install -U pip
            

Installation

Install Powerline.

cmd

sudo pip3 install powerline-status
            

Configuration

Find the install location for powerline.

cmd

pip3 show powerline-status

# output
Name: powerline-status
Version: 2.7
Summary: The ultimate statusline/prompt utility.
Home-page: https://github.com/powerline/powerline
Author: Kim Silkebaekken
Author-email: kim.silkebaekken+vim@gmail.com
License: MIT
Location: /usr/local/lib/python3.6/dist-packages
Requires:
Required-by:
            

From the output above you can see Powerline is installed in the /usr/local/lib/python3.6/dist-packages directory.

Add the following configuration to your ~/.bashrc file.

file

PY3_REPO_ROOT=/usr/local/lib/python3.6/dist-packages

powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
source $PY3_REPO_ROOT/powerline/bindings/bash/powerline.sh
            

Source your ~/.bashrc file.

cmd

source ~/.bashrc
            

At this point Powerline is installed and setup, but the symbols will be all messed up and you will need to select one of the patched fonts that where installed earlier.

In the Ubuntu app follow the below sequence to change the font.

  • Select the Ubuntu icon > Properties
  • Select the Font tab
  • Choose one of the Powerline fonts

Customise Powerline Display

Powerline is highly customisable, configs to alter the appearance are stored in the ~/.config/powerline/themes/shell/default.json file. This is my custom powerline config file.

file

{
  "segments": {
    "above": [
      {
        "left": [
          {
            "function": "powerline.segments.shell.mode"
          },
          {
            "function": "powerline.segments.common.net.hostname",
            "priority": 10
          },
          {
            "function": "powerline.segments.common.env.user",
            "priority": 30
          },
          {
            "function": "powerline.segments.common.env.virtualenv",
            "priority": 50
          },
          {
            "function": "powerline.segments.shell.cwd",
            "priority": 10,
            "args": {
              "use_path_separator": true
            }
          },
          {
            "function": "powerline.segments.common.time.date"
          },
          {
            "function": "powerline.segments.common.time.date",
            "name": "time",
            "args": {
              "format": "%H:%M:%S %A",
              "istime": true
            }
          },
          {
            "function": "powerline.segments.common.vcs.branch",
            "priority": 40
          },
          {
            "function": "powerline.segments.shell.jobnum",
            "priority": 20
          }
        ],
        "right": [
        ]
      },
      {
      }
    ],
    "left": [
      {
        "function": "powerline.segments.shell.mode"
      },
      {
        "function": "powerline.segments.common.time.date",
        "args": {
          "format": "$"
        }
      }
    ],
    "right": [
    ]
  }
}
            

VIM Bindings

To use the VIM bindings add the following config to your ~/.vimrc file.

file

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

TMUX Bindings

To use the TMUX bindings add the following config to your ~/.tmux.conf file.

file

source "/usr/local/lib/python3.6/dist-packages/powerline/bindings/tmux/powerline.conf"
            

Summary

Having the option to run Bash on Windows is a very nice feature. I really like the aesthetics of the Powerline plugin so I am happy to be able to install then on the Ubuntu Bash app.

Updated: 21st May 2019

windows wsl linux bash