summaryrefslogtreecommitdiff
path: root/internal/wizard.zsh
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2020-02-26 16:48:15 +0300
committerromkatv <roman.perepelitsa@gmail.com>2020-02-26 16:48:15 +0300
commit5567ab3850cf0a25021d1837267ad068737f8881 (patch)
tree504f1b0e2f5dd8c7b6315fa1e5df406c6663f6f5 /internal/wizard.zsh
parent3077929e185fa0c5b0646f6fa43c6bc646ea14e2 (diff)
before installing a font, check if it already exists; try to remove if so
Diffstat (limited to 'internal/wizard.zsh')
-rwxr-xr-xinternal/wizard.zsh62
1 files changed, 54 insertions, 8 deletions
diff --git a/internal/wizard.zsh b/internal/wizard.zsh
index b2063079..41e0063d 100755
--- a/internal/wizard.zsh
+++ b/internal/wizard.zsh
@@ -374,28 +374,74 @@ function install_font() {
function ask_font() {
can_install_font || return 0
+ {
+ while true; do
+ clear
+ (( greeting_printed )) || print_greeting
+ flowing -c "%BInstall %b%2FMeslo Nerd Font%f%B?%b"
+ print -P ""
+ print -P ""
+ print -P "%B(y) Yes (recommended).%b"
+ print -P ""
+ print -P "%B(n) No. Use the current font.%b"
+ print -P ""
+ print -P "(q) Quit and do nothing."
+ print -P ""
+
+ local key=
+ read -k key${(%):-"?%BChoice [ynq]: %b"} || quit -c
+ case $key in
+ q) quit;;
+ y) ask_remove_font || return; install_font; break;;
+ n) break;;
+ esac
+ done
+ } always {
+ greeting_printed=1
+ }
+}
+
+function ask_remove_font() {
+ local font
+ local -a fonts
+ local -i protected
+ for font in {,/System,~}/Library/Fonts/**/*[Mm]eslo*.(ttf|otf)(N:A); do
+ [[ -f $font && -r $font ]] || continue
+ [[ $font == ~/Library/Fonts/'MesloLGS NF '(Regular|Bold|Italic|Bold\ Italic).ttf ]] && continue
+ [[ "$(<$font)" == *"MesloLGS NF"$'\0'* ]] || continue
+ fonts+=$font
+ [[ -w ${font:h} ]] || protected=1
+ done
+ (( $#fonts )) || return 0
while true; do
clear
- print_greeting
- flowing -c "%BInstall %b%2FMeslo Nerd Font%f%B?%b"
+ flowing -c "A variant of %2FMeslo Nerd Font%f" is already installed.
print -P ""
+ for font in $fonts; do
+ print -P " %B${font//\%/%%}%b"
+ done
print -P ""
- print -P "%B(y) Yes (recommended).%b"
+ if (( protected )); then
+ flowing Please %Bdelete%b these files and run '%2Fp10k%f %Bconfigure%b.'
+ print
+ exit 0
+ fi
+ flowing -c "%BDelete these files?%b"
print -P ""
- print -P "%B(n) No. Use the current font.%b"
+ print -P "%B(y) Yes (recommended).%b"
print -P ""
+ print -P "(r) Restart from the beginning."
print -P "(q) Quit and do nothing."
print -P ""
local key=
- read -k key${(%):-"?%BChoice [ynq]: %b"} || quit -c
+ read -k key${(%):-"?%BChoice [yrq]: %b"} || quit -c
case $key in
q) quit;;
- y) install_font; break;;
- n) break;;
+ r) return 1;;
+ y) zf_rm -f -- $fonts || quit -c; break;;
esac
done
- greeting_printed=1
}
function ask_diamond() {