mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-25 21:40:08 +00:00
wizard: don't refuse to start if ZDOTDIR is not writable; see #987
This commit is contained in:
parent
c1db3926fe
commit
a3727dcaef
2 changed files with 22 additions and 6 deletions
|
@ -21,10 +21,20 @@ function _p9k_can_configure() {
|
||||||
[[ -o multibyte ]] || { $0_error "multibyte option is not set"; return 1 }
|
[[ -o multibyte ]] || { $0_error "multibyte option is not set"; return 1 }
|
||||||
[[ -e $__p9k_zd ]] || { $0_error "$__p9k_zd_u does not exist"; return 1 }
|
[[ -e $__p9k_zd ]] || { $0_error "$__p9k_zd_u does not exist"; return 1 }
|
||||||
[[ -d $__p9k_zd ]] || { $0_error "$__p9k_zd_u is not a directory"; return 1 }
|
[[ -d $__p9k_zd ]] || { $0_error "$__p9k_zd_u is not a directory"; return 1 }
|
||||||
[[ -w $__p9k_zd ]] || { $0_error "$__p9k_zd_u is not writable"; return 1 }
|
|
||||||
[[ ! -d $__p9k_cfg_path ]] || { $0_error "$__p9k_cfg_path_u is a directory"; return 1 }
|
[[ ! -d $__p9k_cfg_path ]] || { $0_error "$__p9k_cfg_path_u is a directory"; return 1 }
|
||||||
[[ ! -d $__p9k_zshrc ]] || { $0_error "$__p9k_zshrc_u is a directory"; return 1 }
|
[[ ! -d $__p9k_zshrc ]] || { $0_error "$__p9k_zshrc_u is a directory"; return 1 }
|
||||||
|
|
||||||
|
local dir=${__p9k_cfg_path:h}
|
||||||
|
while [[ ! -e $dir && $dir != ${dir:h} ]]; do dir=${dir:h}; done
|
||||||
|
if [[ ! -d $dir ]]; then
|
||||||
|
$0_error "cannot create $__p9k_cfg_path_u because ${dir//\%/%%} is not a directory"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if [[ ! -w $dir ]]; then
|
||||||
|
$0_error "cannot create $__p9k_cfg_path_u because ${dir//\%/%%} is readonly"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
[[ ! -e $__p9k_cfg_path || -f $__p9k_cfg_path || -h $__p9k_cfg_path ]] || {
|
[[ ! -e $__p9k_cfg_path || -f $__p9k_cfg_path || -h $__p9k_cfg_path ]] || {
|
||||||
$0_error "$__p9k_cfg_path_u is a special file"
|
$0_error "$__p9k_cfg_path_u is a special file"
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -505,19 +505,19 @@ function install_font() {
|
||||||
clear
|
clear
|
||||||
case $terminal in
|
case $terminal in
|
||||||
Termux)
|
Termux)
|
||||||
mkdir -p ~/.termux || quit -c
|
command mkdir -p -- ~/.termux || quit -c
|
||||||
run_command "Downloading %BMesloLGS NF Regular.ttf%b" \
|
run_command "Downloading %BMesloLGS NF Regular.ttf%b" \
|
||||||
curl -fsSL -o ~/.termux/font.ttf "$font_base_url/MesloLGS%20NF%20Regular.ttf"
|
curl -fsSL -o ~/.termux/font.ttf "$font_base_url/MesloLGS%20NF%20Regular.ttf"
|
||||||
run_command "Reloading %BTermux%b settings" termux-reload-settings
|
run_command "Reloading %BTermux%b settings" termux-reload-settings
|
||||||
;;
|
;;
|
||||||
iTerm2)
|
iTerm2)
|
||||||
mkdir -p ~/Library/Fonts || quit -c
|
command mkdir -p -- ~/Library/Fonts || quit -c
|
||||||
local style
|
local style
|
||||||
for style in Regular Bold Italic 'Bold Italic'; do
|
for style in Regular Bold Italic 'Bold Italic'; do
|
||||||
local file="MesloLGS NF ${style}.ttf"
|
local file="MesloLGS NF ${style}.ttf"
|
||||||
run_command "Downloading %B$file%b" \
|
run_command "Downloading %B$file%b" \
|
||||||
curl -fsSL -o ~/Library/Fonts/$file.tmp "$font_base_url/${file// /%20}"
|
curl -fsSL -o ~/Library/Fonts/$file.tmp "$font_base_url/${file// /%20}"
|
||||||
zf_mv -f -- ~/Library/Fonts/$file{.tmp,} || quit -c
|
command mv -f -- ~/Library/Fonts/$file{.tmp,} || quit -c
|
||||||
done
|
done
|
||||||
print -nP -- "Changing %BiTerm2%b settings ..."
|
print -nP -- "Changing %BiTerm2%b settings ..."
|
||||||
local size=$iterm2_font_size
|
local size=$iterm2_font_size
|
||||||
|
@ -1590,7 +1590,11 @@ function ask_zshrc_edit() {
|
||||||
add_widget 0 print -P ""
|
add_widget 0 print -P ""
|
||||||
add_widget 1
|
add_widget 1
|
||||||
local modifiable=y
|
local modifiable=y
|
||||||
if [[ -e $__p9k_zshrc && ! -w $__p9k_zshrc ]]; then
|
if [[ ! -w $__p9k_zd ]]; then
|
||||||
|
modifiable=
|
||||||
|
add_widget 0 flowing -c %3FWARNING:%f %2F${__p9k_zd_u//\\/\\\\}%f %3Fis readonly.%f
|
||||||
|
add_widget 0 print -P ""
|
||||||
|
elif [[ -e $__p9k_zshrc && ! -w $__p9k_zshrc ]]; then
|
||||||
local -a stat
|
local -a stat
|
||||||
zstat -A stat +uid -- $__p9k_zshrc || quit -c
|
zstat -A stat +uid -- $__p9k_zshrc || quit -c
|
||||||
if (( stat[1] == EUID )); then
|
if (( stat[1] == EUID )); then
|
||||||
|
@ -1875,6 +1879,8 @@ function generate_config() {
|
||||||
header+=$line
|
header+=$line
|
||||||
header+=$'.\n# Type `p10k configure` to generate another config.\n#'
|
header+=$'.\n# Type `p10k configure` to generate another config.\n#'
|
||||||
|
|
||||||
|
command mkdir -p -- ${__p9k_cfg_path:h} || return
|
||||||
|
|
||||||
if [[ -e $__p9k_cfg_path ]]; then
|
if [[ -e $__p9k_cfg_path ]]; then
|
||||||
unlink $__p9k_cfg_path || return
|
unlink $__p9k_cfg_path || return
|
||||||
fi
|
fi
|
||||||
|
@ -1914,7 +1920,7 @@ fi" || return
|
||||||
[[ ! -f ${(%)__p9k_cfg_path_u} ]] || source ${(%)__p9k_cfg_path_u}" || return
|
[[ ! -f ${(%)__p9k_cfg_path_u} ]] || source ${(%)__p9k_cfg_path_u}" || return
|
||||||
fi
|
fi
|
||||||
(( writable )) || chmod u-w -- $tmp || return
|
(( writable )) || chmod u-w -- $tmp || return
|
||||||
zf_mv -f -- $tmp $__p9k_zshrc || return
|
command mv -f -- $tmp $__p9k_zshrc || return
|
||||||
} always {
|
} always {
|
||||||
zf_rm -f -- $tmp
|
zf_rm -f -- $tmp
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue