Installing Powerline in Windows 11 for VS Code Git bash terminal

Installing Powerline in Windows 11 for VS Code Git bash terminal

Powerline is a great little utility for the Git bash and equally so in VS Code terminal. However it could be a little tedious installing it if you are not too familiar. We are going to cover the steps to install and activate Powerline in Windows 11. It should work if you use Git bash as well as Vs Code terminal.

The steps would be:

  1. Install Powerline for Git bash
  2. Install the Fonts for Powerline support.
  3. Activate Powerline in VS Code.

Install Powerline for Git bash in Windows 11

We would start with installing a Powerline theme for Windows Git bash. We would need to install the theme in the user profile. Navigate to the user profile directory at C:\Users\<username> and create a directory .bash/themes. After creating the directories, navigate into the directory and checkout the theme from GitHub using the following clone command: git clone https://github.com/diesire/git_bash_windows_powerline.git. You should see the theme file named theme.bash inside the git_bash_windows_powerline folder. This is the file that Git need to refer in order for Powerline to work in the bash.

Once you have the theme installed, navigate to C:\Program Files\Git\etc directory and open the file bash.bashrc in your favorite editor. I prefer VS Code for editing as it is handles the Windows permission related issues for the editing files. Insert the following code at the end of bash.bashrc file:

# Theme
THEME=$HOME/.bash/themes/git_bash_windows_powerline/theme.bash
if [ -f $THEME ]; then
   . $THEME
fi
unset THEME

$HOME translates to the user directory at C:\Users\<username> in our example. Make sure you have the theme installed at the correct path. Open a new Git bash session.

Install the Fonts for Powerline support.

Ideally the above steps should work and you should see the Powerline theme if you have the correct Fonts installed and selected. More often that not, it is not the case. Although you would be able to see the color scheme applied fine but you might not see the symbols being rendered correctly.

See the symbols at the either end of the branch name in the screenshot above)

You can find fonts that support Powerline, online. However if you don’t know about any such font already or don’t have a preference yet, you can download a few from https://github.com/powerline/fonts (direct download link). The steps to install them are standard. Unzip them to a folder and right click and Install.

Navigate to the Fonts folder (Windows + s) and ensure that the font is installed. Open a new Git bash window and see if those symbols now render correctly. If they do not, right click on the Git logo on the top left of the bash window and select Options...

Click on Text > Fonts (Select button) to open the Fonts selection option. Choose the Powerline supporting font that you installed.

The symbols should now render correctly.

Activate Powerline in VS Code

Open VS Code and click Ctrl + Shift + P and type Settings and select Preferences: Open Settings (UI).

Search for Fonts and enter the complete name of the font in the Editor: Font Family.

A point to note here is that this would change the font for VS Code as a whole.

Open a new Git bash terminal in VS Code.

You should now see Powerline working your VS Code Git bash Terminal as well.

Let us know if you found this article useful.

Leave a comment

Your email address will not be published.


*