dotfiles/install/lib/fonts.sh

30 lines
1 KiB
Bash

#!/bin/bash
# Nerd Fonts — the configs (wezterm, starship, eza icons) assume
# "JetBrainsMono Nerd Font". Ubuntu's fonts-jetbrains-mono is the plain
# family without the Nerd glyphs, so install from the official release
# into ~/.local/share/fonts.
NERD_FONT_NAME="JetBrainsMono"
NERD_FONT_DIR="$HOME/.local/share/fonts/${NERD_FONT_NAME}NerdFont"
NERD_FONT_VERSION="v3.4.0"
NERD_FONT_SHA256="ef552a3e638f25125c6ad4c51176a6adcdce295ab1d2ffacf0db060caf8c1582"
install_nerd_font() {
if fc-list 2>/dev/null | grep -qi "JetBrainsMono Nerd Font"; then
info "JetBrainsMono Nerd Font already installed"
return
fi
info "Installing ${NERD_FONT_NAME} Nerd Font..."
local url="https://github.com/ryanoasis/nerd-fonts/releases/download/$NERD_FONT_VERSION/${NERD_FONT_NAME}.tar.xz"
local tmp
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' RETURN
download_verified "$url" "$NERD_FONT_SHA256" "$tmp/font.tar.xz"
mkdir -p "$NERD_FONT_DIR"
tar -xJf "$tmp/font.tar.xz" -C "$NERD_FONT_DIR"
fc-cache -f "$NERD_FONT_DIR"
info "Installed to $NERD_FONT_DIR"
}