From ebd32c8cbe079a90148f6f8b67bf371822a1af03 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sun, 28 Jul 2019 10:34:06 +0200 Subject: [PATCH] simplify code --- internal/wizard.zsh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/wizard.zsh b/internal/wizard.zsh index d37a0add..3e1aee7f 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -290,15 +290,17 @@ function _p9k_ask_overwrite() { function _p9k_generate_config() { local base && base="$(< $_p9k_root_dir/config/p10k-$_p9k_style.zsh)" || return local lines=("${(@f)base}") - lines=("${(@)lines/# typeset -g POWERLEVEL9K_MODE=*/ typeset -g POWERLEVEL9K_MODE=$POWERLEVEL9K_MODE}") + function _p9k_sub() { + lines=("${(@)lines/# typeset -g POWERLEVEL9K_$1=*/ typeset -g POWERLEVEL9K_$1=$2}") + } + _p9k_sub MODE $POWERLEVEL9K_MODE if [[ $POWERLEVEL9K_MODE == (powerline|compatible) && $_p9k_style == lean ]]; then - local exp="''" + _p9k_sub VISUAL_IDENTIFIER_EXPANSION "''" elif (( _p9k_caps_narrow_icons )); then - local exp="'\${P9K_VISUAL_IDENTIFIER// }'" + _p9k_sub VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER// }'" else - local exp="'\${P9K_VISUAL_IDENTIFIER}'" + _p9k_sub VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER}'" fi - lines=("${(@)lines/# typeset -g POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION=*/ typeset -g POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION=$exp}") if (( _p9k_lines == 1 )); then local -a tmp local line