mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-12-12 19:18:28 +02:00
before installing a font, check if it already exists; try to remove if so
This commit is contained in:
parent
3077929e18
commit
5567ab3850
@ -374,9 +374,10 @@ function install_font() {
|
||||
|
||||
function ask_font() {
|
||||
can_install_font || return 0
|
||||
{
|
||||
while true; do
|
||||
clear
|
||||
print_greeting
|
||||
(( greeting_printed )) || print_greeting
|
||||
flowing -c "%BInstall %b%2FMeslo Nerd Font%f%B?%b"
|
||||
print -P ""
|
||||
print -P ""
|
||||
@ -391,12 +392,57 @@ function ask_font() {
|
||||
read -k key${(%):-"?%BChoice [ynq]: %b"} || quit -c
|
||||
case $key in
|
||||
q) quit;;
|
||||
y) install_font; break;;
|
||||
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
|
||||
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 ""
|
||||
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(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 [yrq]: %b"} || quit -c
|
||||
case $key in
|
||||
q) quit;;
|
||||
r) return 1;;
|
||||
y) zf_rm -f -- $fonts || quit -c; break;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
function ask_diamond() {
|
||||
while true; do
|
||||
|
Loading…
Reference in New Issue
Block a user