Skip to content

Instantly share code, notes, and snippets.

@anakaiti
Last active June 6, 2025 16:00
Show Gist options
  • Save anakaiti/488e3525da2cbca2b5a840e8155fbe1f to your computer and use it in GitHub Desktop.
Save anakaiti/488e3525da2cbca2b5a840e8155fbe1f to your computer and use it in GitHub Desktop.
Azeret Mono Nerd Fonts Installer
#!/usr/bin/env bash
# Azeret Mono Nerd Fonts Installer
# Usage: wget -O - https://is.gd/install_azeret_mono_nf | sudo bash
set -euo pipefail
readonly FONT_URL="https://fonts.googleapis.com/css2?family=Azeret+Mono:ital,wght@0,100..900;1,100..900&display=swap"
readonly INSTALL_DIR="/usr/share/fonts/truetype/azeret-mono"
readonly REQUIRED_COMMANDS=(wget grep xargs docker fc-cache)
log() {
local level="$1"
shift
local message="$*"
local timestamp
timestamp=$(date '+%H:%M:%S')
case "$level" in
"INFO")
echo -e "\033[32m[${timestamp}]\033[0m $message"
;;
"ERROR")
echo -e "\033[31m[${timestamp}] ERROR:\033[0m $message" >&2
;;
"SUCCESS")
echo -e "\033[32m[${timestamp}] ✓\033[0m $message"
;;
esac
}
# Check root privileges
if [[ $EUID -ne 0 ]]; then
log "ERROR" "This script must be run as root. Please use sudo."
exit 1
fi
# Validate required commands
missing_commands=()
for cmd in "${REQUIRED_COMMANDS[@]}"; do
if ! command -v "$cmd" &> /dev/null; then
missing_commands+=("$cmd")
fi
done
if [[ ${#missing_commands[@]} -ne 0 ]]; then
echo "Error: The following commands are required but not installed: ${missing_commands[*]}"
exit 1
fi
log "INFO" "Starting installation..."
# Clean and create directories
[[ -d "$INSTALL_DIR" ]] && rm -rf "$INSTALL_DIR"
mkdir -p "$INSTALL_DIR"
# Download and patch fonts
temp_dir=$(mktemp -d)
cd "$temp_dir"
log "INFO" "Downloading fonts..."
wget -q -O - "$FONT_URL" | grep -oE 'https://[^"]+\.ttf' | xargs wget -q
log "INFO" "Patching with Nerd Fonts..."
mkdir -p out
docker run --rm -v "$PWD:/in:Z" -v "$PWD/out:/out:Z" nerdfonts/patcher
# Install fonts
mv out/*.ttf "$INSTALL_DIR"
fc-cache -fv > /dev/null 2>&1
# Cleanup
rm -rf "$temp_dir"
log "SUCCESS" "Installation complete! Fonts installed to $INSTALL_DIR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment