From f5b1bf0915e69211a8a5ef2f3c97f51c424d9b81 Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Sun, 24 Sep 2023 23:46:09 +0300 Subject: [PATCH] feat(dfm): install nerdfonts --- local/bin/dfm | 6 ++++++ scripts/install-fonts.sh | 44 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100755 scripts/install-fonts.sh diff --git a/local/bin/dfm b/local/bin/dfm index 4addc8c..b80288c 100755 --- a/local/bin/dfm +++ b/local/bin/dfm @@ -32,6 +32,7 @@ function section_install "cheat-databases:Install cheat external cheatsheet databases" "composer:Install composer" "dotenv:Install dotenv-linter" + "fonts:Install programming fonts" "gh:Install GitHub CLI Extensions" "go:Install Go Packages" "imagick:Install ImageMagick CLI" @@ -48,6 +49,7 @@ function section_install case "$1" in all) $0 install macos + $0 install fonts $0 install antigen $0 brew install $0 install pip @@ -89,6 +91,10 @@ function section_install | sh -s -- -b "$XDG_BIN_HOME" \ && msg_yay "dotenv-linter installed!" ;; + fonts) + bash "$DOTFILES/scripts/install-fonts.sh" \ + && msg_yay "Installed fonts!" + ;; fzf) bash "$DOTFILES/scripts/install-fzf.sh" \ && msg_yay "fzf installed!" diff --git a/scripts/install-fonts.sh b/scripts/install-fonts.sh new file mode 100755 index 0000000..b4c3994 --- /dev/null +++ b/scripts/install-fonts.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +# Install NerdFonts +# +# shellcheck source="shared.sh" +source "$HOME/.dotfiles/scripts/shared.sh" + +GIT_REPO="https://github.com/ryanoasis/nerd-fonts.git" +TMP_PATH="$XDG_CACHE_HOME/nerd-fonts" + +msg "-- NerdFonts --" + +fonts=( + Hack + IntelOneMono + JetBrainsMono + OpenDyslexic + SpaceMono +) + +if [ ! -d "$TMP_PATH" ]; then + git clone --filter=blob:none --sparse "$GIT_REPO" "$TMP_PATH" +fi + +cd "$TMP_PATH" || { + msg_err "No such folder $TMP_PATH" + exit 1 +} + +for ext in "${fonts[@]}"; do + # Trim spaces + ext=${ext// /} + # Skip comments + if [[ ${ext:0:1} == "#" ]]; then continue; fi + + msg_run "Adding $ext to sparse-checkout" + git sparse-checkout add "patched-fonts/$ext" + echo "" +done + +msg "Starting to install NerdFonts..." + +./install.sh -s ${fonts[*]} + +msg_ok "Done"