Skip to content

Instantly share code, notes, and snippets.

@matthewjberger
Last active July 26, 2024 20:48
Show Gist options
  • Save matthewjberger/7dd7e079f282f8138a9dc3b045ebefa0 to your computer and use it in GitHub Desktop.
Save matthewjberger/7dd7e079f282f8138a9dc3b045ebefa0 to your computer and use it in GitHub Desktop.
Install a nerd font on ubuntu

1.) Download a Nerd Font

2.) Unzip and copy to ~/.fonts

3.) Run the command fc-cache -fv to manually rebuild the font cache

@mcarvalho1
Copy link

Hi guys, after testing several linux distros and having to configure and customize my terminal and shell every time, I decided to create this script that downloads directly from the Nerd Fonts repository, use it as you like and if you want to contribute something, feel free.

The documentation on how to use the script is in the readme:
https://github.com/mcarvalho1/Nerd-fonts-Downloader-Script

@pedroigor91
Copy link

Thanks @mcarvalho1!

@7adidaz
Copy link

7adidaz commented Apr 30, 2024

@donovan @Sephyros thanks both

@ASRodrigo1
Copy link

Thanks @mcarvalho1 !

@Madiuk
Copy link

Madiuk commented May 19, 2024

Hi guys, after testing several linux distros and having to configure and customize my terminal and shell every time, I decided to create this script that downloads directly from the Nerd Fonts repository, use it as you like and if you want to contribute something, feel free.

The documentation on how to use the script is in the readme: https://github.com/mcarvalho1/Nerd-fonts-Downloader-Script

This is beautiful.

@zyzyx159
Copy link

I made a small, but useful to me, change to @donovan code. I added code to look up the latest version of nerd fonts and download those.

#!/bin/bash

declare -a fonts=(
BitstreamVeraSansMono
CascadiaCode
CodeNewRoman
DroidSansMono
FiraCode
FiraMono
Go-Mono
Hack
Hermit
JetBrainsMono
Meslo
Noto
Overpass
ProggyClean
RobotoMono
SourceCodePro
SpaceMono
Ubuntu
UbuntuMono
)

version=$(curl -s 'https://api.github.com/repos/ryanoasis/nerd-fonts/releases/latest' | jq -r '.name')
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/${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

@momodev19
Copy link

had to move the font in /usr/share/fonts

@laedit
Copy link

laedit commented Jun 28, 2024

Another variant, which installs fonts passed on args (allows to install new fonts without modifying the script) and download directly the latest version:

#!/bin/bash
set -euo pipefail

fonts_dir="$HOME/.local/share/fonts"

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

for font in "$@"; do
    zip_file="$font.zip"
    download_url="https://github.com/ryanoasis/nerd-fonts/releases/latest/download/$zip_file"
    echo "Downloading $download_url"
    wget -O "/tmp/$zip_file" "$download_url"
    unzip "/tmp/$zip_file" -d "/tmp/$font/"
    mv /tmp/$font/*.ttf $fonts_dir
    rm "/tmp/$zip_file"
    rm "/tmp/$font/" -rf
done

fc-cache -fv

@mike-clark-8192
Copy link

Check out Nerd Font Downloader (nfdl): https://github.com/rubiin/nfdl
It requires node(js) to run.
It presents a (fuzzy searchable) list of Nerd Fonts which you can choose from to download.
It tries to put the font in the right place for user fonts (per operating system).
On Linux and macOS it will even try to run fc-cache for you, after downloading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment