How to install powerline for Bash on Fedora with git branch support

I assume that you know what powerline is, if not, you can read about it here. In this post, I will show how to use it to get a better bash prompt.

Let’s install it.

Terminal window
sudo dnf install powerline

Now you have to configure bash to use powerline by default. Edit ~/.bashrc file and add at the end:

Terminal window
if [ -f `which powerline-daemon` ]; then
powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
. /usr/share/powerline/bash/powerline.sh
fi

The newly opened terminal will use powerline.

Fedora - bash, powerline

Now, let’s add information about current git branch.

Create powerline configuration file.

Terminal window
mkdir -p ~/.config/powerline

Set theme.

Terminal window
cat <<-'EOF' > ~/.config/powerline/config.json
{
"ext": {
"shell": {
"theme": "default_leftonly"
}
}
}
EOF

Load new configuration

Terminal window
powerline-daemon --replace

Bash prompt should display currently used git branch.

Fedora - bash, powerline, git branch