Skip to content

Instantly share code, notes, and snippets.

@matthewjberger
Last active May 14, 2024 21:14
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

@hreinn91
Copy link

I ended up using nerdfonts too:

font pango: MesloLGS NF Regular 10

I basically did this to install the fonts: https://gist.github.com/matthewjberger/7dd7e079f282f8138a9dc3b045ebefa0
Downloaded the fonts and placed them in ~/.fonts

@ifthenelse
Copy link

ifthenelse commented May 23, 2021

On Debian:
/usr/local/share/fonts/ to install fonts system-wide
~/.local/share/fonts/ or ~/.fonts to install fonts just for the current user

So, this is what I did to install Meslo Nerd font on Raspberry Pi OS, for my user:

sudo apt install wget fontconfig \
&& wget -P ~/.local/share/fonts https://github.com/ryanoasis/nerd-fonts/releases/latest/download/Meslo.zip \
&& cd ~/.local/share/fonts && unzip Meslo.zip && rm *Windows* && rm Meslo.zip && fc-cache -fv

@crazyaccess
Copy link

Thanks

@gnmearacaun
Copy link

4.) List fira fonts with
fc-list | grep -i "fira"|awk -F: '{print $2}' |sort|uniq

@abuyusif01
Copy link

good resource

@shashinvision
Copy link

1 - just copy the bash script bellow and save with [yourname].sh

#/bin/bash
# install DroidSansMono Nerd Font --> u can choose another at: https://www.nerdfonts.com/font-downloads
echo "[-] Download fonts [-]"
echo "https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/DroidSansMono.zip"
wget https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/DroidSansMono.zip
unzip DroidSansMono.zip -d ~/.fonts
fc-cache -fv
echo "done!"

2 - Open a terminal and execute the scritpt with:

bash [yourname].sh

This work for me, and select this font in my terminal :D Thank you very much :D

@meramsey
Copy link

meramsey commented Aug 5, 2021

Just used this and is reusable with any link to the zip file for user level installation copy and paste :)
image

font_url='https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/FiraCode.zip'; font_name=${font_url##*/}; wget ${font_url} && unzip ${font_name} -d ~/.fonts && fc-cache -fv ;

@haiderkhalid
Copy link

thanks works like a champ

@donovan
Copy link

donovan commented Dec 23, 2021

#!/bin/bash

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

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

@tnfru
Copy link

tnfru commented May 26, 2022

#!/bin/bash

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

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

This script was the only thing that actually worked for me. Thank you.

@afifabroory
Copy link

Thanks!

@jbcpollak
Copy link

@donovan awesome script, TY.

@hiAndrewQuinn
Copy link

+1 to @donovan 's script, wonderful and easy to read

@p6002
Copy link

p6002 commented Mar 5, 2023

What is ~/.fonts? Directory?

@matthewjberger
Copy link
Author

@p6002 yep, it's a directory

@devHaitham481
Copy link

works! thanks

@Firsto
Copy link

Firsto commented Apr 28, 2023

thanks

@Sephyros
Copy link

Sephyros commented May 10, 2023

Well, I'm a beginner in this art of creating scripts, so the script below is certainly not optimized or error-proof, I used a good part of @donovan's code, I just changed the use of wget to a git clone using the sparse option, guaranteeing the most current version of the font and the install described in the official documentation, it can also be changed to the powershell installation but as it is not my case at the moment, I did not use it. In fact, bandwidth consumption is higher because it downloads the repository (even if only partially), something that direct download does not, so there is a certain amount of "waste".

#!/bin/bash

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

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

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

echo -e "\e[0;32mScript:\e[0m \e[0;34mClonning\e[0m \e[0;31mNerdFonts\e[0m \e[0;34mrepo (sparse)\e[0m"
git clone --filter=blob:none --sparse git@github.com:ryanoasis/nerd-fonts
cd nerd-fonts

for font in "${fonts[@]}"; do
    echo -e "\e[0;32mScript:\e[0m \e[0;34mClonning font:\e[0m \e[0;31m${font}\e[0m"
    git sparse-checkout add "patched-fonts/${font}"
    echo -e "\e[0;32mScript:\e[0m \e[0;34mInstalling font:\e[0m \e[0;31m${font}\e[0m"
    ./install.sh "${font}"
done

echo -e "\e[0;32mScript:\e[0m \e[0;34mCleaning the mess...\e[0m"
cd ../
rm -rf nerd-fonts```

@p6002
Copy link

p6002 commented May 10, 2023

Still waiting for proper documentation how to install it

@EricEon
Copy link

EricEon commented May 13, 2023

@p6002 for linux, open a text editor and paste the code from @donovan . Then you can save it as installFonts.sh. Your will then have to make it runnable from the properties context menu for the file. Then run it in a terminal with ./installFonts.sh

@p6002
Copy link

p6002 commented May 13, 2023

Thanks, but I have already made several approaches to these fonts, hours-long approaches.
There were always unfixable problems, errors, bad characters. Which was frustrating enough, since it's just a theme and should work with a single command.
For now I'm watching the project and waiting for someone to write proper documentation with steps on how to install this theme. Currently it's such a mess there that I think only the author can use it.

@hiAndrewQuinn
Copy link

hiAndrewQuinn commented Oct 8, 2023

It took an embarrassingly long amount of time for me to realize nerd-fonts the Github repo already comes with an install.sh script.

git clone --depth 1 https://github.com/ryanoasis/nerd-fonts.git    # warning: takes a while

cd nerd-fonts/
./install.sh FiraCode

(or whatever other font you want -- or all of them if you just run ./install.sh by itself.

@wpplumber
Copy link

Thank you, @hiAndrewQuinn

@stuaxo
Copy link

stuaxo commented Nov 7, 2023

@hiAndrewQuinn's example should probably be on the main README considering the amount of us that have ended up here.

@p6002
Copy link

p6002 commented Nov 7, 2023

I still waiting for proper documentation how to install and use it.
In the meantime, I started the rack, I learned how to use Docker, I run services through Docker Compose and several VMs without any problems. But I still can't install the fonts...

@Tolomeo
Copy link

Tolomeo commented Dec 23, 2023

@Sephyros absolutely amazing 👍

@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 !

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