1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-11-22 12:20:07 +00:00

wizard: don't refuse to start if ZDOTDIR is not writable; see #987

This commit is contained in:
Roman Perepelitsa 2020-08-30 13:40:12 +02:00
parent c1db3926fe
commit a3727dcaef
2 changed files with 22 additions and 6 deletions

View file

@ -21,10 +21,20 @@ function _p9k_can_configure() {
[[ -o multibyte ]] || { $0_error "multibyte option is not set"; 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 }
[[ -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_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 ]] || {
$0_error "$__p9k_cfg_path_u is a special file"
return 1

View file

@ -505,19 +505,19 @@ function install_font() {
clear
case $terminal in
Termux)
mkdir -p ~/.termux || quit -c
command mkdir -p -- ~/.termux || quit -c
run_command "Downloading %BMesloLGS NF Regular.ttf%b" \
curl -fsSL -o ~/.termux/font.ttf "$font_base_url/MesloLGS%20NF%20Regular.ttf"
run_command "Reloading %BTermux%b settings" termux-reload-settings
;;
iTerm2)
mkdir -p ~/Library/Fonts || quit -c
command mkdir -p -- ~/Library/Fonts || quit -c
local style
for style in Regular Bold Italic 'Bold Italic'; do
local file="MesloLGS NF ${style}.ttf"
run_command "Downloading %B$file%b" \
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
print -nP -- "Changing %BiTerm2%b settings ..."
local size=$iterm2_font_size
@ -1590,7 +1590,11 @@ function ask_zshrc_edit() {
add_widget 0 print -P ""
add_widget 1
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
zstat -A stat +uid -- $__p9k_zshrc || quit -c
if (( stat[1] == EUID )); then
@ -1875,6 +1879,8 @@ function generate_config() {
header+=$line
header+=$'.\n# Type `p10k configure` to generate another config.\n#'
command mkdir -p -- ${__p9k_cfg_path:h} || return
if [[ -e $__p9k_cfg_path ]]; then
unlink $__p9k_cfg_path || return
fi
@ -1914,7 +1920,7 @@ fi" || return
[[ ! -f ${(%)__p9k_cfg_path_u} ]] || source ${(%)__p9k_cfg_path_u}" || return
fi
(( writable )) || chmod u-w -- $tmp || return
zf_mv -f -- $tmp $__p9k_zshrc || return
command mv -f -- $tmp $__p9k_zshrc || return
} always {
zf_rm -f -- $tmp
}