Install Nerd Fonts in Linux

When working in Neovim you may require custom icons to display specific things (like file types in lualine, or icons in gitsigns). Most of these plugins rely on Nerd Fonts - project that patches developer-oriented fonts with additional icons.

To install these fonts you need to download them from their site, extract to your font directory and update fonts cache. Below is the script to do it:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#! /usr/bin/env sh

release="v3.4.0"
main_link="https://github.com/ryanoasis/nerd-fonts/releases/download/$release"

# space-separated list of fonts
fonts="JetBrainsMono Ubuntu"

for font in $fonts; do
    link="$main_link/$font.zip"
    wget -O /tmp/"$font".zip "$link"
    unzip -o /tmp/"$font".zip -d "$HOME/.local/share/fonts"
    rm /tmp/"$font".zip
done

fc-cache -f -v

You need to replace release variable with current release (available on latest Nerd Font release), and fonts with space-separated list of your fonts.