LINUX

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

#fedora , #git , #bash

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.

sudo dnf install powerline

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

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
Fedora - bash, powerline

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

Create powerline configuration file.

mkdir -p ~/.config/powerline

Set theme.

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

Load new configuration

powerline-daemon --replace

Bash prompt should display currently used git branch.

Fedora - bash, powerline, git branch
Fedora - bash, powerline, git branch