mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-02-06 16:50:22 +00:00
Add strict error handling to all scripts: - 13 scripts get `set -euo pipefail` - install-macos-defaults.sh gets `set -uo pipefail` (without -e) because defaults write commands may fail on newer macOS versions - install-cargo-packages.sh: also add missing source of shared.sh
66 lines
1.2 KiB
Bash
Executable File
66 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
# @description Install NerdFonts
|
|
#
|
|
# shellcheck source="shared.sh"
|
|
source "$DOTFILES/config/shared.sh"
|
|
|
|
GIT_REPO="https://github.com/ryanoasis/nerd-fonts.git"
|
|
TMP_PATH="$XDG_CACHE_HOME/nerd-fonts"
|
|
|
|
msgr run "Starting to install NerdFonts"
|
|
|
|
fonts=(
|
|
JetBrainsMono
|
|
OpenDyslexic
|
|
)
|
|
|
|
# Function to clone or update the NerdFonts repository
|
|
clone_or_update_repo()
|
|
{
|
|
if [ ! -d "$TMP_PATH" ]; then
|
|
git clone --quiet --filter=blob:none --sparse --depth=1 "$GIT_REPO" "$TMP_PATH"
|
|
fi
|
|
|
|
cd "$TMP_PATH" || { msgr err "No such folder $TMP_PATH"; exit 1; }
|
|
}
|
|
|
|
# Function to add fonts to sparse-checkout
|
|
add_fonts_to_sparse_checkout()
|
|
{
|
|
for font in "${fonts[@]}"; do
|
|
# Trim spaces
|
|
font=${font// /}
|
|
# Skip comments
|
|
if [[ ${font:0:1} == "#" ]]; then continue; fi
|
|
|
|
msgr run "Adding $font to sparse-checkout"
|
|
git sparse-checkout add "patched-fonts/$font"
|
|
echo ""
|
|
done
|
|
}
|
|
|
|
# Function to install NerdFonts
|
|
install_fonts()
|
|
{
|
|
msgr run "Starting to install NerdFonts..."
|
|
# shellcheck disable=SC2048,SC2086
|
|
./install.sh -q -s ${fonts[*]}
|
|
msgr run_done "Done"
|
|
}
|
|
|
|
remove_tmp_path()
|
|
{
|
|
rm -rf "$TMP_PATH"
|
|
}
|
|
|
|
main()
|
|
{
|
|
clone_or_update_repo
|
|
add_fonts_to_sparse_checkout
|
|
install_fonts
|
|
remove_tmp_path
|
|
}
|
|
|
|
main "$@"
|