Skip to content

Instantly share code, notes, and snippets.

@jessenich
Last active June 1, 2024 05:34
Show Gist options
  • Select an option

  • Save jessenich/9b39b229b8f9cbbeed5059d60beed014 to your computer and use it in GitHub Desktop.

Select an option

Save jessenich/9b39b229b8f9cbbeed5059d60beed014 to your computer and use it in GitHub Desktop.

Revisions

  1. jessenich revised this gist Apr 29, 2023. 1 changed file with 29 additions and 33 deletions.
    62 changes: 29 additions & 33 deletions install-nerd-fonts.sh
    Original file line number Diff line number Diff line change
    @@ -1,37 +1,33 @@
    #!/bin/bash
    #!/usr/bin/env bash

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

    version=$(curl -s "https://api.github.com/repos/ryanoasis/nerd-fonts/releases/latest" | grep -Po '"tag_name":\s*"\Kv[^"]+')
    fonts_dir="${XDG_DATA_HOME:-$HOME/.local/share}/fonts"
    mkdir -p "$fonts_dir"
    gh_release=$(curl -s "https://api.github.com/repos/ryanoasis/nerd-fonts/releases/latest")

    for font in "${fonts[@]}"; do
    download_url="https://github.com/ryanoasis/nerd-fonts/releases/download/$version/$font.zip"
    echo "Downloading $download_url"
    curl -fsSL "$download_url" -o "/tmp/$font.zip"
    unzip "/tmp/$font.zip" -d "$fonts_dir"
    rm -f "/tmp/$font.zip"
    done
    if [[ "${fonts[0]}" = "all" ]]; then
    # Project all font names into source array
    echo "$gh_release" | \
    jq -r '.assets | .[].name | rtrimstr(".zip")' | \
    while IFS="" read -r font; do fonts+=($font); done
    else
    fonts=("$@")
    fi

    find "$fonts_dir" -name '*Windows Compatible*' -delete
    fc-cache -fv
    version=$(echo "$gh_release" | jq -r '.tag_name | ltrimstr("v")')
    fonts_dir="${XDG_DATA_HOME:-$HOME/.local/share}/fonts"
    mkdir -p "$fonts_dir"

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

    find "$fonts_dir" -name '*Windows Compatible*' -delete
    fc-cache -fv
    }

    __main "$@"
  2. jessenich revised this gist Apr 7, 2023. 1 changed file with 5 additions and 6 deletions.
    11 changes: 5 additions & 6 deletions install-nerd-fonts.sh
    Original file line number Diff line number Diff line change
    @@ -21,17 +21,16 @@ declare -a fonts=(
    UbuntuMono
    )

    version='2.1.0'
    version=$(curl -s "https://api.github.com/repos/ryanoasis/nerd-fonts/releases/latest" | grep -Po '"tag_name":\s*"\Kv[^"]+')
    fonts_dir="${XDG_DATA_HOME:-$HOME/.local/share}/fonts"
    mkdir -p "$fonts_dir"

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

    find "$fonts_dir" -name '*Windows Compatible*' -delete
  3. jessenich revised this gist Apr 5, 2023. 1 changed file with 1 addition and 4 deletions.
    5 changes: 1 addition & 4 deletions install-nerd-fonts.sh
    Original file line number Diff line number Diff line change
    @@ -23,10 +23,7 @@ declare -a fonts=(

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

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

    for font in "${fonts[@]}"; do
    zip_file="${font}.zip"
  4. jessenich revised this gist Apr 5, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install-nerd-fonts.sh
    Original file line number Diff line number Diff line change
    @@ -22,7 +22,7 @@ declare -a fonts=(
    )

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

    if [[ ! -d "$fonts_dir" ]]; then
    mkdir -p "$fonts_dir"
  5. jessenich created this gist Sep 23, 2022.
    41 changes: 41 additions & 0 deletions install-nerd-fonts.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    #!/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