How to install Powerline fonts on WSL?
Asked Answered
D

4

36

I'm using Windows Subsystem for Linux (WSL 2) with Oh My Zsh to pimp my bash, but I can't make the Ubuntu terminal render the Powerline fonts properly. Any idea on how to set up WSL to work with these fonts?

enter image description here

Duky answered 29/7, 2020 at 7:33 Comment(1)
It appears to me that there is the original vim powerline, the powerline-shell, and now also Microsofts Powerline for WSL which is actually just posh-git/oh-my-posh. I think question/tags/answers need to specify which variant we're alking about here.Rakehell
D
65

I was installing the fonts in the Ubuntu system, but it is Windows that is rendering the characters from the terminal, so I should install the fonts on Windows (facepalm).

I followed this blog post to install the Powerline fonts on Windows, and then I had to change the font in the settings of the WSL terminal:

enter image description here

I selected the font DejaVu Sans Mono for Powerline, which works well with the robbyrussell theme of Oh My Zsh, but there are other options.

Running the same command now rendered the characters as expected:

enter image description here

The shell command I used to test the Powerline fonts came from this GitHub gist.

Duky answered 29/7, 2020 at 7:33 Comment(3)
I have installed the PL version of Cascadia font. But it's not visible in that menu you show. Only the normal fonts are.Glycoprotein
I have Cascadia installed on Windows as well, and I can see it in the fonts list. Are you sure the installation of the font went through?Stadia
A little add-on: once having instantiated the terminal, one has to right-click of terminal window header and select the proper fonts. From this it was not clear, as I was trying to right-click on the ubuntu.exe icon and not on the terminal window.Tinworks
H
22
  1. Download the required .ttf file from the powerline github repo.
  2. In Windows, open the file by double-clicking on it. It will show two options: Print and Install. Choose Install.
  3. Right-click on the WSL terminal's title-bar > Properties > Font > DejaVu Sans Mono for Powerline.
Hypoblast answered 19/8, 2021 at 10:0 Comment(1)
This way is faster, don't need all those other fonts, thanks!Reverential
E
6

If you are running a Debian or Ubuntu a package available to install the Powerline Fonts with the following command:

sudo apt-get install fonts-powerline

otherwise you can do

git clone https://github.com/powerline/fonts.git
cd fonts
./install.sh
cd ..
rm -rf fonts
Effect answered 4/12, 2020 at 9:22 Comment(2)
How will this work in WSL2 ?Reverential
The only no-nonsense solution. Works on my WSL2 Ubuntu 20 image. Great! Run this in the Ubuntu/Debian terminal as you would on any Linux OS. Installing this rid of all the question marks.Janitajanith
F
0

A simple way would be to add Powerline fonts to Windows and then using them in the terminal. Basically, Powerline fonts will get installed at ~/.local/share/fonts inside WSL. These fonts can be copied to someplace on your windows directory.

e.g. cp ~/.local/share/fonts/* /mnt/d/fonts/

This will copy all the ttf files to a folder names fonts on my d drive.

Now press that windows icon from your keyboard and search for Font Settings. Under Add Fonts, you can drag and drop the ttf files. Windows will automatically install all these fonts. You can then go to your Terminal and set the required font.

Fradin answered 3/7, 2021 at 12:13 Comment(1)
The recommended package has no fonts. I installed fonts-dejavu and copied its requisite package's fonts from /usr/share/fonts/truetype/dejavu.Flavone

© 2022 - 2024 — McMap. All rights reserved.