Development

How to Install Nerd Fonts on Ubuntu Linux

Captain Salem 2 min read

How to Install Nerd Fonts on Linux

Nerd Fonts is a project that patches developer-targeted fonts with many glyphs (icons). It includes programming ligatures and is designed to enhance the appearance of source code. It is a fork of the Fantastic Machines’ “For the Poor” font, which includes only the Powerline glyphs.

Nerd Fonts includes additional glyphs from popular icon sets and patches them onto the original fonts. The result is a font that includes a broader range of glyphs and is more visually appealing for geeks.

This tutorial will teach how to install the Nerd Fonts pack on Ubuntu or any Debian-based distribution.

Install Nerd Fonts on Ubuntu

To install the Nerd Fonts package, start by cloning the Nerd Fonts repo:

 bash git clone --filter=blob:none --sparse git@github.com:ryanoasis/nerd-fonts

You can also use the HTTPS command:

git clone --filter=blob:none --sparse https://github.com/ryanoasis/nerd-fonts.git

If you do not wish to clone the repository, you can navigate to the releases page and download the source code zip.

Once you have the repo, navigate into the directory:

cd nerd-fonts

Use the provided installer script to install and configure the fonts on your system as:

./install.sh

Installing Specific Nerd Font

Sometimes, you may want to install only some of the fonts on your machine. In that a case, you can head to the Nerd Fonts releases page and download the font you desire.

For example, to install the Hack Nerd font, we can start by downloading the font zip:

wget https://github.com/ryanoasis/nerd-fonts/releases/download/v2.2.2/Hack.zip

Unzip the font:

unzip Hack.zip

Move the font files into the ~/.fonts or ~/.local/share/fonts directory

mv *.ttf ~/.fonts
mv *ttf ~/.local/share/fonts

NOTE: Use one of the commands provided above!!!

You can now set the font for your editor, terminal, etc.

Sometimes youmay want the font files to be accessible for all users in the system. In such a case, you can move the font files to /usr/share/fonts/

sudo mv *.ttf /usr/share/fonts/

Finally, rebuild the font cache with the command:

fc-cache -fv

The following script should allow you to quickly setup the nerd fonts manually.

#!/bin/bash

declare -a fonts=(
    Agave
    AnonymousPro
    Arimo
    AurulentSansMono
    BigBlueTerminal
    BitstreamVeraSansMono
    CascaidaCode
    CodeNewRoman
    Cousine
    DaddyTimeMono
    DejaVuSansMono
    DroidSansMono
    FantasqueSansMono
    FiraCode
    FiraMono
    Go-Mono
    Gohu
    Hack
    Hasklig
    HeavyData
    Hermit
    iA-Writer
    IBMPlexMono
    Inconsolate
    InconsolataGo
    InconsolataLGC
    Iosevka
    JetBrainsMono
    Lekton
    LiberationMono
    Lilex
    Meslo
    Monofur
    Mononoki
    Monoid
    MPlus
    NerdFontsSymbolsOnly
    Noto
    OpenDyslexic
    Overpass
    ProFont
    ProggyClean
    RobotoMono
    ShareTechMono
    Terminus
    Tinos
    Ubuntu
    UbuntuMono
    VictorMono
)

version='2.1.0'
fonts_dir="${HOME}/.local/share/fonts"

if [[ ! -d "$fonts_dir" ]]; then
    mkdir -p "$fonts_dir"
fi

for font in "${fonts[@]}"; do
    zip_file="${font}.zip"
    download_url="https://github.com/ryanoasis/nerd-fonts/releases/download/v${version}/${zip_file}"
    echo "Downloading $download_url"
    wget "$download_url"
    unzip "$zip_file" -d "$fonts_dir"
    rm "$zip_file"
done

find "$fonts_dir" -name '*Windows Compatible*' -delete

fc-cache -fv

Note: Remove the fonts you do not wish to install from the script above.

Conclusion

In this post, you learned how to install and configure the Nerd Fonts pack on Debian-based distributions or any Linux distribution. We hope you enjoyed this tutorial.

Leave us comments below for compliments, complaints, support, and more.

Share
Comments
More from Cloudenv

Cloudenv

Developer Tips, Tricks and Tutorials.

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to Cloudenv.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.