Skip to content

Instantly share code, notes, and snippets.

@matthewjberger
Last active February 5, 2023 02:06
Embed
What would you like to do?
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

@adibdz
Copy link

adibdz commented Dec 30, 2018

Thank you !!

@Tanaka-Suzuki
Copy link

thanks

@skyghis
Copy link

skyghis commented Dec 1, 2019

Thanks.

BTW, It is possible to use ~/.local/share/fonts instead of ~/.fonts.

@t0gu
Copy link

t0gu commented May 17, 2020

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

@LinuxIsCool
Copy link

Thanks.

BTW, It is possible to use ~/.local/share/fonts instead of ~/.fonts.

Yes on newer versions of ubuntu according to: https://askubuntu.com/questions/3697/how-do-i-install-fonts?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

@imdudu1
Copy link

imdudu1 commented Sep 17, 2020

thx XD

@vadviktor
Copy link

You may want to exclude Windows related versions of the fonts.

Here is my Ansible task to give a hint:

---
- name: Update from git
  ansible.builtin.git:
    repo: "https://github.com/ryanoasis/nerd-fonts.git"
    dest: "{{ ansible_env.HOME }}/src/ikon/nerd-fonts"
    depth: 1
    force: yes

- name: Select fonts to install
  ansible.builtin.find:
    recurse: yes
    use_regex: yes
    paths: "{{ ansible_env.HOME }}/src/ikon/nerd-fonts/patched-fonts"
    patterns:
      - '^.*?((?!Windows).)*?\.ttf$'
  register: fonts_to_install

#- debug: var=fonts_to_install

- ansible.builtin.copy:
    dest: "{{ ansible_env.HOME }}/.local/share/fonts/{{ item.path | basename }}"
    src: "{{ item.path }}"
    remote_src: yes
  loop: "{{ fonts_to_install.files }}"
  notify:
    - update font cache

@smac89
Copy link

smac89 commented Feb 20, 2021

If you prefer not to checkout too many files from the repo, just use svn to download the folder you want. For example, I just needed Meslo L-DZ Regular, so I did the following:

svn co --depth=empty https://github.com/ryanoasis/nerd-fonts.git/trunk nerd-fonts
cd nerd-fonts
svn up patched-fonts --depth=empty
svn up patched-fonts/Meslo --depth=empty
svn up patched-fonts/Meslo/L-DZ --depth=empty
svn up patched-fonts/Meslo/L-DZ/Regular --depth=empty
svn up patched-fonts/Meslo/L-DZ/Regular/complete --depth=files

Admittedly a bit repetitive, but depending on your internet connection you would have spent more time achieving the same results with git. You could also decide to write a script for this if you deem it necessary.

All you need to do to keep it up to date is (from the root of the repo):

svn up

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

sudo apt install fontconfig
cd ~
wget https://github.com/ryanoasis/nerd-fonts/releases/download/v2.3.0-RC/Meslo.zip
mkdir -p .local/share/fonts
unzip Meslo.zip -d .local/share/fonts
cd .local/share/fonts
rm *Windows*
cd ~
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

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