updated: 21st of May 2019
published: 18th of May 2019
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.
If you have just installed the Ubuntu app, perform an update.
sudo apt update -y && sudo apt upgrade -y
Powerline requires patched fonts to correctly display icons, symbols and nice text.
Install and update Python PIP
sudo apt install -y python3-pip
sudo pip3 install -U pip
Install Powerline.
sudo pip3 install powerline-status
Find the install location for powerline.
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.
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.
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.
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.
{
"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": [
]
}
}
To use the VIM bindings add the following config to your ~/.vimrc file.
set rtp+=/usr/local/lib/python3.6/dist-packages/powerline/bindings/vim
set laststatus=2
set t_Co=256
To use the TMUX bindings add the following config to your ~/.tmux.conf file.
source "/usr/local/lib/python3.6/dist-packages/powerline/bindings/tmux/powerline.conf"
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.
https://powerline.readthedocs.io/en/latest/installation/linux.html
https://powerline.readthedocs.io/en/latest/usage/shell-prompts.html#bash-prompt
https://iamnotmyself.com/2017/04/15/setting-up-powerline-shell-on-windows-subsystem-for-linux/
https://powerline.readthedocs.io/en/latest/usage/other.html#vim-statusline