From 9ce0a0551e4e19680e622b5cf1afd17f2d47ce13 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 20 Feb 2020 08:31:53 +0100 Subject: [PATCH] attempt to make locale workarounds more robust --- internal/icons.zsh | 8 ++++---- internal/p10k.zsh | 13 +++++++------ powerlevel10k.zsh-theme | 4 ++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/internal/icons.zsh b/internal/icons.zsh index 5baf1c2d..7e919cd1 100644 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -643,9 +643,9 @@ function _p9k_init_icons() { # Sadly, this is a part of public API. Its use is emphatically discouraged. function print_icon() { eval "$__p9k_intro" - if (( ! $+_p9k__locale )); then + if (( ! $+__p9k_locale )); then _p9k_init_locale - [[ -z $_p9k__locale ]] || local LC_ALL=$_p9k__locale + [[ -z $__p9k_locale ]] || local LC_ALL=$__p9k_locale fi _p9k_init_icons local var=POWERLEVEL9K_$1 @@ -663,9 +663,9 @@ function print_icon() { # overrides into account. function get_icon_names() { eval "$__p9k_intro" - if (( ! $+_p9k__locale )); then + if (( ! $+__p9k_locale )); then _p9k_init_locale - [[ -z $_p9k__locale ]] || local LC_ALL=$_p9k__locale + [[ -z $__p9k_locale ]] || local LC_ALL=$__p9k_locale fi _p9k_init_icons local key diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 4ec8c898..1a9ac5b9 100644 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -5160,7 +5160,7 @@ _p9k_dump_instant_prompt() { local prompt_dir=${(q)prompt_dir} zmodload zsh/langinfo if [[ \${langinfo[CODESET]:-} != (utf|UTF)(-|)8 ]]; then - local lc=${(q)${${${_p9k__locale:-${(M)LC_CTYPE:#*.(utf|UTF)(-|)8}}:-${(M)LC_ALL:#*.(utf|UTF)(-|)8}}}:-${(M)LANG:#*.(utf|UTF)(-|)8}} + local lc=${(q)${${${__p9k_locale:-${(M)LC_CTYPE:#*.(utf|UTF)(-|)8}}:-${(M)LC_ALL:#*.(utf|UTF)(-|)8}}}:-${(M)LANG:#*.(utf|UTF)(-|)8}} local LC_ALL=\${lc:-\${\${(@M)\$(locale -a 2>/dev/null):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8}} fi" >&$fd print -r -- ' @@ -5812,9 +5812,9 @@ _p9k_precmd_impl() { (( __p9k_enabled )) || return - if (( ! $+_p9k__locale )); then + if (( ! $+__p9k_locale )); then _p9k_init_locale - [[ -z $_p9k__locale ]] || local LC_ALL=$_p9k__locale + [[ -z $__p9k_locale ]] || local LC_ALL=$__p9k_locale fi if ! zle || [[ -z $_p9k__param_sig ]]; then @@ -5962,9 +5962,9 @@ function _p9k_prompt_overflow_bug() { function _p9k_init_locale() { zmodload zsh/langinfo if [[ ${langinfo[CODESET]:-} != (utf|UTF)(-|)8 ]]; then - typeset -g _p9k__locale=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} + typeset -g __p9k_locale=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} else - typeset -g _p9k__locale= + typeset -g __p9k_locale= fi } @@ -7030,7 +7030,7 @@ _p9k_must_init() { [[ $sig == $_p9k__param_sig ]] && return 1 _p9k_deinit fi - _p9k__param_pat=$'v52\1'${ZSH_VERSION}$'\1'${ZSH_PATCHLEVEL}$'\1' + _p9k__param_pat=$'v53\1'${ZSH_VERSION}$'\1'${ZSH_PATCHLEVEL}$'\1' _p9k__param_pat+=$'${#parameters[(I)POWERLEVEL9K_*]}\1${(%):-%n%#}\1$GITSTATUS_LOG_LEVEL\1' _p9k__param_pat+=$'$GITSTATUS_ENABLE_LOGGING\1$GITSTATUS_DAEMON\1$GITSTATUS_NUM_THREADS\1' _p9k__param_pat+=$'$DEFAULT_USER\1${ZLE_RPROMPT_INDENT:-1}\1$P9K_SSH\1$__p9k_ksh_arrays' @@ -7441,6 +7441,7 @@ _p9k_deinit() { (( $+_p9k__iterm2_precmd )) && functions[iterm2_precmd]=$_p9k__iterm2_precmd (( $+_p9k__iterm2_decorate_prompt )) && functions[iterm2_decorate_prompt]=$_p9k__iterm2_decorate_prompt unset -m '(_POWERLEVEL9K_|P9K_|_p9k_)*~(P9K_SSH|P9K_TTY)' + [[ -n $__p9k_locale ]] || unset __p9k_locale } typeset -gi __p9k_enabled=0 diff --git a/powerlevel10k.zsh-theme b/powerlevel10k.zsh-theme index ee6b38bf..d9ded15a 100644 --- a/powerlevel10k.zsh-theme +++ b/powerlevel10k.zsh-theme @@ -24,13 +24,13 @@ local -a match mbegin mend reply local -i MBEGIN MEND OPTIND local MATCH REPLY OPTARG IFS=$'\'' \t\n\0'\'' - [[ -z $_p9k__locale ]] || local LC_ALL=$_p9k__locale' + [[ -z $__p9k_locale ]] || local LC_ALL=$__p9k_locale' # The same as above but without `local -a reply` and `local REPLY`. typeset -gr __p9k_intro_no_reply='emulate -L zsh -o no_hist_expand -o extended_glob -o no_prompt_bang -o prompt_percent -o no_prompt_subst -o no_aliases -o no_bg_nice -o typeset_silent local -a match mbegin mend local -i MBEGIN MEND OPTIND local REPLY OPTARG IFS=$'\'' \t\n\0'\'' - [[ -z $_p9k__locale ]] || local LC_ALL=$_p9k__locale' + [[ -z $__p9k_locale ]] || local LC_ALL=$__p9k_locale' } () {