2019-09-03 08:18:19 +00:00
|
|
|
typeset -gr __p9k_wizard_columns=55
|
2019-07-31 09:40:38 +00:00
|
|
|
typeset -gr __p9k_wizard_lines=21
|
2019-09-06 09:30:11 +00:00
|
|
|
typeset -gr __p9k_zd=${ZDOTDIR:-$HOME}
|
|
|
|
typeset -gr __p9k_zd_u=${${${(q)__p9k_zd}/#(#b)${(q)HOME}(|\/*)/'~'$match[1]}//\%/%%}
|
2019-07-28 10:16:05 +00:00
|
|
|
typeset -gr __p9k_cfg_basename=.p10k.zsh
|
2020-01-19 14:24:12 +00:00
|
|
|
typeset -gr __p9k_cfg_path_o=$__p9k_zd/$__p9k_cfg_basename
|
|
|
|
typeset -gr __p9k_cfg_path=${__p9k_cfg_path_o:A}
|
2019-07-28 10:16:05 +00:00
|
|
|
typeset -gr __p9k_cfg_path_u=$__p9k_zd_u/$__p9k_cfg_basename
|
2020-01-19 14:24:12 +00:00
|
|
|
typeset -gr __p9k_zshrc=${${:-$__p9k_zd/.zshrc}:A}
|
2019-07-28 15:29:56 +00:00
|
|
|
typeset -gr __p9k_zshrc_u=$__p9k_zd_u/.zshrc
|
2019-09-06 09:30:11 +00:00
|
|
|
typeset -gr __p9k_root_dir_u=${${${(q)__p9k_root_dir}/#(#b)${(q)HOME}(|\/*)/'~'$match[1]}//\%/%%}
|
2019-07-28 10:16:05 +00:00
|
|
|
|
2020-02-16 01:06:08 +00:00
|
|
|
typeset -gr __p9k_writeable_zsh=$(test ! -e $__p9k_zshrc || test -w $__p9k_zshrc)
|
2020-02-16 00:51:11 +00:00
|
|
|
|
2019-07-28 10:16:05 +00:00
|
|
|
function _p9k_can_configure() {
|
|
|
|
[[ $1 == '-q' ]] && local -i q=1 || local -i q=0
|
|
|
|
function $0_error() {
|
2019-08-05 08:37:04 +00:00
|
|
|
(( q )) || print -rP "%1F[ERROR]%f %Bp10k configure%b: $1" >&2
|
2019-07-28 10:16:05 +00:00
|
|
|
}
|
|
|
|
{
|
2019-08-05 18:23:30 +00: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 }
|
|
|
|
[[ -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 }
|
2019-07-28 10:16:05 +00:00
|
|
|
|
2019-08-05 18:23:30 +00:00
|
|
|
[[ ! -e $__p9k_cfg_path || -f $__p9k_cfg_path || -h $__p9k_cfg_path ]] || {
|
2019-07-28 10:16:05 +00:00
|
|
|
$0_error "$__p9k_cfg_path_u is a special file"
|
2019-08-05 18:23:30 +00:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
[[ -r $__p9k_root_dir/config/p10k-lean.zsh ]] || {
|
2019-07-28 10:19:51 +00:00
|
|
|
$0_error "cannot read $__p9k_root_dir_u/config/p10k-lean.zsh"
|
2019-08-05 18:23:30 +00:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
[[ -r $__p9k_root_dir/config/p10k-classic.zsh ]] || {
|
2019-07-28 10:19:51 +00:00
|
|
|
$0_error "cannot read $__p9k_root_dir_u/config/p10k-classic.zsh"
|
2019-08-05 18:23:30 +00:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
[[ ! -e $__p9k_zshrc || -f $__p9k_zshrc || -h $__p9k_zshrc ]] || {
|
2019-07-28 15:29:56 +00:00
|
|
|
$0_error "$__p9k_zshrc_u a special file"
|
2019-08-05 18:23:30 +00:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
[[ ! -e $__p9k_zshrc || -r $__p9k_zshrc ]] || {
|
2019-07-28 15:29:56 +00:00
|
|
|
$0_error "$__p9k_zshrc_u is not readable"
|
2019-08-05 18:23:30 +00:00
|
|
|
return 1
|
|
|
|
}
|
2020-02-16 00:51:11 +00:00
|
|
|
|
2019-08-05 18:23:30 +00:00
|
|
|
(( LINES >= __p9k_wizard_lines && COLUMNS >= __p9k_wizard_columns )) || {
|
2019-07-29 15:43:25 +00:00
|
|
|
$0_error "terminal size too small; must be at least $__p9k_wizard_columns x $__p9k_wizard_lines"
|
2019-08-05 18:23:30 +00:00
|
|
|
return 1
|
|
|
|
}
|
2019-10-26 18:43:38 +00:00
|
|
|
[[ -t 0 && -t 1 ]] || { $0_error "no TTY"; return 2 }
|
|
|
|
return 0
|
2019-07-28 10:16:05 +00:00
|
|
|
} always {
|
|
|
|
unfunction $0_error
|
|
|
|
}
|
|
|
|
}
|
2019-07-28 16:53:45 +00:00
|
|
|
|
|
|
|
function p9k_configure() {
|
2020-02-01 21:03:42 +00:00
|
|
|
eval "$__p9k_intro"
|
2019-08-26 10:05:42 +00:00
|
|
|
(
|
2019-11-29 09:55:30 +00:00
|
|
|
set -- -f
|
|
|
|
source $__p9k_root_dir/internal/wizard.zsh
|
2019-09-04 06:13:16 +00:00
|
|
|
)
|
|
|
|
local ret=$?
|
|
|
|
case $ret in
|
2019-11-21 08:24:29 +00:00
|
|
|
0) source $__p9k_cfg_path; _p9k__force_must_init=1;;
|
2019-09-04 06:13:16 +00:00
|
|
|
69) return 0;;
|
|
|
|
*) return $ret;;
|
|
|
|
esac
|
2019-07-28 16:53:45 +00:00
|
|
|
}
|