2020-08-27 09:57:12 +02:00
|
|
|
# Fewer than 47 columns will probably work. Haven't tried it.
|
|
|
|
typeset -gr __p9k_wizard_columns=47
|
|
|
|
# The bottleneck is ask_tails with nerd fonts. Everything else works fine with 12 lines.
|
|
|
|
typeset -gr __p9k_wizard_lines=14
|
2019-09-06 11:30:11 +02:00
|
|
|
typeset -gr __p9k_zd=${ZDOTDIR:-$HOME}
|
|
|
|
typeset -gr __p9k_zd_u=${${${(q)__p9k_zd}/#(#b)${(q)HOME}(|\/*)/'~'$match[1]}//\%/%%}
|
2020-01-19 16:24:12 +02:00
|
|
|
typeset -gr __p9k_zshrc=${${:-$__p9k_zd/.zshrc}:A}
|
2019-07-28 17:29:56 +02:00
|
|
|
typeset -gr __p9k_zshrc_u=$__p9k_zd_u/.zshrc
|
2019-09-06 11:30:11 +02:00
|
|
|
typeset -gr __p9k_root_dir_u=${${${(q)__p9k_root_dir}/#(#b)${(q)HOME}(|\/*)/'~'$match[1]}//\%/%%}
|
2019-07-28 12:16:05 +02:00
|
|
|
|
|
|
|
function _p9k_can_configure() {
|
|
|
|
[[ $1 == '-q' ]] && local -i q=1 || local -i q=0
|
|
|
|
function $0_error() {
|
2019-08-05 10:37:04 +02:00
|
|
|
(( q )) || print -rP "%1F[ERROR]%f %Bp10k configure%b: $1" >&2
|
2019-07-28 12:16:05 +02:00
|
|
|
}
|
2020-04-05 07:25:10 +02:00
|
|
|
typeset -g __p9k_cfg_path_o=${POWERLEVEL9K_CONFIG_FILE:=${ZDOTDIR:-~}/.p10k.zsh}
|
|
|
|
typeset -g __p9k_cfg_basename=${__p9k_cfg_path_o:t}
|
|
|
|
typeset -g __p9k_cfg_path=${__p9k_cfg_path_o:A}
|
|
|
|
typeset -g __p9k_cfg_path_u=${${${(q)__p9k_cfg_path_o}/#(#b)${(q)HOME}(|\/*)/'~'$match[1]}//\%/%%}
|
2019-07-28 12:16:05 +02:00
|
|
|
{
|
2019-08-05 20:23:30 +02:00
|
|
|
[[ -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 }
|
|
|
|
[[ ! -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 }
|
2019-07-28 12:16:05 +02:00
|
|
|
|
2020-08-30 13:40:12 +02:00
|
|
|
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
|
|
|
|
|
2019-08-05 20:23:30 +02:00
|
|
|
[[ ! -e $__p9k_cfg_path || -f $__p9k_cfg_path || -h $__p9k_cfg_path ]] || {
|
2019-07-28 12:16:05 +02:00
|
|
|
$0_error "$__p9k_cfg_path_u is a special file"
|
2019-08-05 20:23:30 +02:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
[[ ! -e $__p9k_zshrc || -f $__p9k_zshrc || -h $__p9k_zshrc ]] || {
|
2019-07-28 17:29:56 +02:00
|
|
|
$0_error "$__p9k_zshrc_u a special file"
|
2019-08-05 20:23:30 +02:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
[[ ! -e $__p9k_zshrc || -r $__p9k_zshrc ]] || {
|
2019-07-28 17:29:56 +02:00
|
|
|
$0_error "$__p9k_zshrc_u is not readable"
|
2019-08-05 20:23:30 +02:00
|
|
|
return 1
|
|
|
|
}
|
2020-02-16 11:30:40 +02:00
|
|
|
local style
|
|
|
|
for style in lean lean-8colors classic rainbow pure; do
|
|
|
|
[[ -r $__p9k_root_dir/config/p10k-$style.zsh ]] || {
|
|
|
|
$0_error "$__p9k_root_dir_u/config/p10k-$style.zsh is not readable"
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
done
|
2020-02-16 02:51:11 +02:00
|
|
|
|
2019-08-05 20:23:30 +02:00
|
|
|
(( LINES >= __p9k_wizard_lines && COLUMNS >= __p9k_wizard_columns )) || {
|
2020-08-27 09:57:12 +02:00
|
|
|
$0_error "terminal size too small; must be at least $__p9k_wizard_columns columns by $__p9k_wizard_lines lines"
|
2019-08-05 20:23:30 +02:00
|
|
|
return 1
|
|
|
|
}
|
2021-11-15 08:25:17 +02:00
|
|
|
[[ -t 0 && -t 1 ]] || {
|
|
|
|
$0_error "no TTY"
|
|
|
|
return 2
|
|
|
|
}
|
2019-10-26 20:43:38 +02:00
|
|
|
return 0
|
2019-07-28 12:16:05 +02:00
|
|
|
} always {
|
|
|
|
unfunction $0_error
|
|
|
|
}
|
|
|
|
}
|
2019-07-28 18:53:45 +02:00
|
|
|
|
|
|
|
function p9k_configure() {
|
2020-02-01 23:03:42 +02:00
|
|
|
eval "$__p9k_intro"
|
2020-04-05 07:25:10 +02:00
|
|
|
_p9k_can_configure || return
|
2019-08-26 12:05:42 +02:00
|
|
|
(
|
2019-11-29 11:55:30 +02:00
|
|
|
set -- -f
|
2020-07-04 07:03:46 +02:00
|
|
|
builtin source $__p9k_root_dir/internal/wizard.zsh
|
2019-09-04 08:13:16 +02:00
|
|
|
)
|
|
|
|
local ret=$?
|
|
|
|
case $ret in
|
2020-07-04 07:03:46 +02:00
|
|
|
0) builtin source $__p9k_cfg_path; _p9k__force_must_init=1;;
|
2019-09-04 08:13:16 +02:00
|
|
|
69) return 0;;
|
|
|
|
*) return $ret;;
|
|
|
|
esac
|
2019-07-28 18:53:45 +02:00
|
|
|
}
|