1.) Download a Nerd Font
2.) Unzip and copy to ~/.fonts
3.) Run the command fc-cache -fv
to manually rebuild the font cache
1.) Download a Nerd Font
2.) Unzip and copy to ~/.fonts
3.) Run the command fc-cache -fv
to manually rebuild the font cache
You've got a typo in your script that's causing an error. On the line where you have ls ="${font}.zip", you're mistakenly using the ls command instead of assigning the zip file name to a variable. This incorrect usage leads to the script failing to locate the font file, resulting in a "No such file or directory" error when it tries to download and unzip the font. By correcting that line to zip_file="${font}.zip", you'll properly assign the zip file name to the zip_file variable, allowing the download URL to be constructed correctly and the font installation to proceed without issues.
Script below with fixes and works on 24.04
#!/bin/bash
declare -a fonts=(
BitstreamVeraSansMono
CascadiaCode
CodeNewRoman
DroidSansMono
FiraCode
FiraMono
Go-Mono
Hack
Hermit
JetBrainsMono
Meslo
Noto
Overpass
ProggyClean
RobotoMono
SourceCodePro
SpaceMono
Ubuntu
UbuntuMono
)
version=$(curl -s 'https://api.github.com/repos/ryanoasis/nerd-fonts/releases/latest' | jq -r '.name')
if [ -z "$version" ] || [ "$version" = "null" ]; then
version="v3.2.1"
fi
echo "latest version: $version"
fonts_dir="${HOME}/.local/share/fonts"
#fonts_dir="/usr/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/${version}/${zip_file}"
echo "Downloading $download_url"
wget "$download_url"
unzip -o "$zip_file" -d "$fonts_dir" # Added the -o option here to allow replacing
rm "$zip_file"
done
find "$fonts_dir" -name 'Windows Compatible' -delete
fc-cache -fv
I made him better.