From 056a8b83167914ca0ca0be71acdd24439c73197f Mon Sep 17 00:00:00 2001 From: Leonardo Uieda Date: Fri, 13 Sep 2024 11:09:17 -0300 Subject: [PATCH] Install Nerd Fonts to separate folders --- bash/.bash/functions/fonts.sh | 29 ++++++++++++++++++----------- bash/.bash/functions/pdf.sh | 10 ++++++---- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/bash/.bash/functions/fonts.sh b/bash/.bash/functions/fonts.sh index 77cd850..5c6d6f3 100644 --- a/bash/.bash/functions/fonts.sh +++ b/bash/.bash/functions/fonts.sh @@ -1,16 +1,23 @@ # Dowload and install Nerd Fonts https://www.nerdfonts.com nerdfonts() { - if [[ $# -le 0 ]]; then - echo "Usage: nerdfonts FontName" - echo "" - echo "The name should be the package in the nerdfonts release page: https://github.com/ryanoasis/nerd-fonts/releases/latest" - else - wget -P ~/.local/share/fonts https://github.com/ryanoasis/nerd-fonts/releases/latest/download/$1.zip \ - && cd ~/.local/share/fonts \ - && unzip $1.zip \ - && rm $1.zip \ - && fc-cache -fv - cd - +read -r -d '' NERDFONTS_HELP <<-'EOF' +Usage: nerdfonts FontName + +Download a Nerd Font and install it locally. + +The FontName should be the package in the nerdfonts release page: +https://github.com/ryanoasis/nerd-fonts/releases/latest + +EOF + if [[ $# -ne 1 ]]; then + echo "$NERDFONTS_HELP" + return 1; fi + outdir="$HOME/.local/share/fonts/$1" + baseurl="https://github.com/ryanoasis/nerd-fonts/releases/latest/download" + wget -P $outdir $baseurl/$1.zip \ + && unzip $outdir/$1.zip -d $outdir \ + && rm $outdir/$1.zip \ + && fc-cache -fv } diff --git a/bash/.bash/functions/pdf.sh b/bash/.bash/functions/pdf.sh index 592413e..8e2b70b 100644 --- a/bash/.bash/functions/pdf.sh +++ b/bash/.bash/functions/pdf.sh @@ -11,16 +11,18 @@ pdfcmyk() { pdfcompress() { read -r -d '' PDFCOMPRESS_HELP <<-'EOF' -Usage: pdfcompress [INPUT] [OUTPUT] +Usage: pdfcompress [LEVEL] INPUT OUTPUT Use Ghostscript to lower the DPI of images in a PDF. +LEVEL should be one of: screen [default], default, ebook, printer, prepress + EOF - if [[ $# == 0 ]]; then + if [[ $# -le 1 ]]; then echo "$PDFCOMPRESS_HELP"; - return 0; + return 1; fi - gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook \ + gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen \ -dNOPAUSE -dQUIET -dBATCH -dDetectDuplicateImages \ -dCompressFonts=true -sOutputFile=$2 $1 }