wizard: fix handling for $ZDOTDIR and $HOME with special symbols ("%", "$", etc.)

This commit is contained in:
romkatv 2019-09-06 11:30:11 +02:00
parent 072f7be8ff
commit ef6f90f598
2 changed files with 11 additions and 11 deletions

View File

@ -1,13 +1,13 @@
typeset -gr __p9k_wizard_columns=55
typeset -gr __p9k_wizard_lines=21
typeset -gr __p9k_zd=${${ZDOTDIR:-$HOME}:A}
typeset -gr __p9k_zd_u=${${${(q-)__p9k_zd}/#(#b)$HOME(|\/*)/'~'$match[1]}//\%/%%}
typeset -gr __p9k_zd=${ZDOTDIR:-$HOME}
typeset -gr __p9k_zd_u=${${${(q)__p9k_zd}/#(#b)${(q)HOME}(|\/*)/'~'$match[1]}//\%/%%}
typeset -gr __p9k_cfg_basename=.p10k.zsh
typeset -gr __p9k_cfg_path=$__p9k_zd/$__p9k_cfg_basename
typeset -gr __p9k_cfg_path_u=$__p9k_zd_u/$__p9k_cfg_basename
typeset -gr __p9k_zshrc=$__p9k_zd/.zshrc
typeset -gr __p9k_zshrc_u=$__p9k_zd_u/.zshrc
typeset -gr __p9k_root_dir_u=${${${(q-)__p9k_root_dir}/#(#b)$HOME(|\/*)/'~'$match[1]}//\%/%%}
typeset -gr __p9k_root_dir_u=${${${(q)__p9k_root_dir}/#(#b)${(q)HOME}(|\/*)/'~'$match[1]}//\%/%%}
function _p9k_can_configure() {
emulate -L zsh

View File

@ -1346,14 +1346,14 @@ function generate_config() {
function write_zshrc() {
if [[ -e $__p9k_zshrc ]]; then
local lines=(${(f)"$(<$__p9k_zshrc)"})
local f1=$__p9k_cfg_path
local f2=$__p9k_cfg_path_u
local f3=${__p9k_cfg_path_u/#\~\//\$HOME\/}
local f4=${__p9k_cfg_path_u/#\~\//\"\$HOME\"\/}
local f5="'$f1'"
local f6="\"$f1\""
local f7="\"$f3\""
if [[ -n ${(@M)lines:#(#b)[^#]#([^[:IDENT:]]|)source[[:space:]]##($f1|$f2|$f3|$f4|$f5|$f6|$f7)*} ]]; then
local f0=$__p9k_cfg_path
local f1=${(q)f0}
local f2=${(q-)f0}
local f3=${(q+)f0}
local f4=${(qq)f0}
local f5=${(qqq)f0}
local g1=${${(q)__p9k_cfg_path}/#(#b)${(q)HOME}\//'~/'}
if [[ -n ${(@M)lines:#(#b)[^#]#([^[:IDENT:]]|)source[[:space:]]##($f1|$f2|$f3|$f4|$f5|$g1)(|[[:space:]]*|'#'*)} ]]; then
flowing +c No changes have been made to %4F$__p9k_zshrc_u%f because it already sources %2F$__p9k_cfg_path_u%f.
return
fi