37 lines
1 KiB
Bash
Executable file
37 lines
1 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
get_latest_nerd_font_release() {
|
|
basename "$(curl -Ls -o /dev/null -w "%{url_effective}" https://github.com/ryanoasis/nerd-fonts/releases/latest)"
|
|
}
|
|
|
|
install_font() {
|
|
if [[ "$#" -lt 1 ]]; then
|
|
echo "[!] No font file given to download!" >&2
|
|
return 1
|
|
fi
|
|
|
|
local latest_release font_name
|
|
font_name="$1"
|
|
latest_release="$(get_latest_nerd_font_release)"
|
|
tmpdir="$(mktemp -d)"
|
|
|
|
curl -Lo "${tmpdir}/${font_name}" "https://github.com/ryanoasis/nerd-fonts/releases/download/${latest_release}/${font_name}"
|
|
mkdir "${tmpdir}/font_files"
|
|
tar -C "${tmpdir}/font_files" -xJf "${tmpdir}/${font_name}"
|
|
|
|
mkdir -p "${HOME}/.local/share/fonts"
|
|
find "${tmpdir}/font_files" -type f \( -iname '*.otf' -o -iname '*.ttf' \) -exec mv {} "${HOME}/.local/share/fonts/" \;
|
|
|
|
rm -rf "${tmpdir}"
|
|
}
|
|
|
|
for font in "FiraCode.tar.xz" "Hack.tar.xz" "FiraMono.tar.xz"; do
|
|
echo "[+] Installing ${font}..."
|
|
install_font "${font}"
|
|
done
|
|
|
|
echo "[+] Reloading font cache..."
|
|
fc-cache -f
|
|
|