Last active
August 8, 2023 03:07
-
-
Save naranyala/31887c6ab76bb4efad98a0eec8177a6a to your computer and use it in GitHub Desktop.
easy-peasy installing font, directly from nerdfont
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Set font installation directory | |
font_install_dir="$HOME/.local/share/fonts" | |
# List of available Nerd Font options | |
nerd_fonts=( | |
"Hack" | |
"FiraCode" | |
"Meslo" | |
"SourceCodePro" | |
"Terminus" | |
"Monoid" | |
"Noto" | |
"Iosevka" | |
"JetBrainsMono" | |
"UbuntuMono" | |
# Add more options here | |
) | |
# Prompt user to select a Nerd Font option | |
echo "Select a Nerd Font option:" | |
select font_option in "${nerd_fonts[@]}"; do | |
if [[ " ${nerd_fonts[@]} " =~ " ${font_option} " ]]; then | |
chosen_font_name="$font_option" | |
break | |
else | |
echo "Invalid selection. Please choose a valid option." | |
fi | |
done | |
# Path to the downloaded zip file | |
zip_file="${font_install_dir}/${chosen_font_name}.zip" | |
# Download Nerd Font if not already downloaded | |
if [ ! -f "$zip_file" ]; then | |
nerd_font_url="https://github.com/ryanoasis/nerd-fonts/releases/latest/download/${chosen_font_name}.zip" | |
# Check if the URL is reachable | |
if wget --spider "$nerd_font_url" 2>/dev/null; then | |
wget -P "$font_install_dir" "$nerd_font_url" | |
else | |
echo "Error: The download link is not reachable or the file doesn't exist." | |
exit 1 | |
fi | |
fi | |
# Create a directory for the font | |
font_dir="$font_install_dir/$chosen_font_name" | |
mkdir -p "$font_dir" | |
# Unzip the downloaded font | |
unzip -o "$zip_file" -d "$font_dir" | |
# Rebuild the font cache | |
fc-cache -fv | |
echo "Nerd Font '$chosen_font_name' installed and font cache rebuilt." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment