mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-22 12:20:07 +00:00
when the user's locale is misconfigured, set it to utf8 at the top level
fixes #469
This commit is contained in:
parent
47e8c1b38c
commit
a12f7ac8ee
4 changed files with 27 additions and 28 deletions
|
@ -3,12 +3,6 @@ typeset -gA icons
|
||||||
function _p9k_init_icons() {
|
function _p9k_init_icons() {
|
||||||
[[ $+_p9k_icon_mode == 1 && $_p9k_icon_mode == $POWERLEVEL9K_MODE/$POWERLEVEL9K_LEGACY_ICON_SPACING ]] && return
|
[[ $+_p9k_icon_mode == 1 && $_p9k_icon_mode == $POWERLEVEL9K_MODE/$POWERLEVEL9K_LEGACY_ICON_SPACING ]] && return
|
||||||
typeset -g _p9k_icon_mode=$POWERLEVEL9K_MODE/$POWERLEVEL9K_LEGACY_ICON_SPACING
|
typeset -g _p9k_icon_mode=$POWERLEVEL9K_MODE/$POWERLEVEL9K_LEGACY_ICON_SPACING
|
||||||
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}
|
|
||||||
else
|
|
||||||
typeset -g _p9k_locale=
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $POWERLEVEL9K_LEGACY_ICON_SPACING == true ]]; then
|
if [[ $POWERLEVEL9K_LEGACY_ICON_SPACING == true ]]; then
|
||||||
local s=
|
local s=
|
||||||
|
@ -614,7 +608,6 @@ function _p9k_init_icons() {
|
||||||
# Sadly, this is a part of public API. Its use is emphatically discouraged.
|
# Sadly, this is a part of public API. Its use is emphatically discouraged.
|
||||||
function _p9k_print_icon() {
|
function _p9k_print_icon() {
|
||||||
_p9k_init_icons
|
_p9k_init_icons
|
||||||
[[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale
|
|
||||||
local icon_name=$1
|
local icon_name=$1
|
||||||
local var_name=POWERLEVEL9K_${icon_name}
|
local var_name=POWERLEVEL9K_${icon_name}
|
||||||
if [[ -n "${(tP)var_name}" ]]; then
|
if [[ -n "${(tP)var_name}" ]]; then
|
||||||
|
@ -631,7 +624,6 @@ function _p9k_print_icon() {
|
||||||
# overrides into account.
|
# overrides into account.
|
||||||
function _p9k_get_icon_names() {
|
function _p9k_get_icon_names() {
|
||||||
_p9k_init_icons
|
_p9k_init_icons
|
||||||
[[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale
|
|
||||||
# Iterate over a ordered list of keys of the icons array
|
# Iterate over a ordered list of keys of the icons array
|
||||||
for key in ${(@kon)icons}; do
|
for key in ${(@kon)icons}; do
|
||||||
echo -n "POWERLEVEL9K_$key: "
|
echo -n "POWERLEVEL9K_$key: "
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
if [[ $__p9k_sourced != 4 ]]; then
|
if [[ $__p9k_sourced != 5 ]]; then
|
||||||
>&2 print -P ""
|
>&2 print -P ""
|
||||||
>&2 print -P "[%F{1}ERROR%f]: Corrupted powerlevel10k installation."
|
>&2 print -P "[%F{1}ERROR%f]: Corrupted powerlevel10k installation."
|
||||||
>&2 print -P ""
|
>&2 print -P ""
|
||||||
|
@ -140,6 +140,10 @@ function getColorCode() {
|
||||||
# Sadly, this is a part of public API. Its use is emphatically discouraged.
|
# Sadly, this is a part of public API. Its use is emphatically discouraged.
|
||||||
function print_icon() {
|
function print_icon() {
|
||||||
eval "$__p9k_intro"
|
eval "$__p9k_intro"
|
||||||
|
if (( ! $+_p9k__locale )); then
|
||||||
|
_p9k_init_locale
|
||||||
|
[[ -z $_p9k__locale ]] || local LC_ALL=$_p9k__locale
|
||||||
|
fi
|
||||||
(( $+functions[_p9k_print_icon] )) || source "${__p9k_root_dir}/internal/icons.zsh"
|
(( $+functions[_p9k_print_icon] )) || source "${__p9k_root_dir}/internal/icons.zsh"
|
||||||
_p9k_print_icon "$@"
|
_p9k_print_icon "$@"
|
||||||
}
|
}
|
||||||
|
@ -151,6 +155,10 @@ function print_icon() {
|
||||||
# overrides into account.
|
# overrides into account.
|
||||||
function get_icon_names() {
|
function get_icon_names() {
|
||||||
eval "$__p9k_intro"
|
eval "$__p9k_intro"
|
||||||
|
if (( ! $+_p9k__locale )); then
|
||||||
|
_p9k_init_locale
|
||||||
|
[[ -z $_p9k__locale ]] || local LC_ALL=$_p9k__locale
|
||||||
|
fi
|
||||||
(( $+functions[_p9k_get_icon_names] )) || source "${__p9k_root_dir}/internal/icons.zsh"
|
(( $+functions[_p9k_get_icon_names] )) || source "${__p9k_root_dir}/internal/icons.zsh"
|
||||||
_p9k_get_icon_names "$@"
|
_p9k_get_icon_names "$@"
|
||||||
}
|
}
|
||||||
|
@ -188,7 +196,6 @@ function _p9k_declare() {
|
||||||
(( set )) && typeset -g _$2=${(P)2} || typeset -g _$2=$3
|
(( set )) && typeset -g _$2=${(P)2} || typeset -g _$2=$3
|
||||||
;;
|
;;
|
||||||
-e)
|
-e)
|
||||||
[[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale
|
|
||||||
if (( set )); then
|
if (( set )); then
|
||||||
local v=${(P)2}
|
local v=${(P)2}
|
||||||
typeset -g _$2=${(g::)v}
|
typeset -g _$2=${(g::)v}
|
||||||
|
@ -529,7 +536,6 @@ _p9k_get_icon() {
|
||||||
if [[ $_p9k_ret == $'\1'* ]]; then
|
if [[ $_p9k_ret == $'\1'* ]]; then
|
||||||
_p9k_ret=${_p9k_ret[2,-1]}
|
_p9k_ret=${_p9k_ret[2,-1]}
|
||||||
else
|
else
|
||||||
[[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale
|
|
||||||
_p9k_ret=${(g::)_p9k_ret}
|
_p9k_ret=${(g::)_p9k_ret}
|
||||||
[[ $_p9k_ret != $'\b'? ]] || _p9k_ret="%{$_p9k_ret%}" # penance for past sins
|
[[ $_p9k_ret != $'\b'? ]] || _p9k_ret="%{$_p9k_ret%}" # penance for past sins
|
||||||
fi
|
fi
|
||||||
|
@ -767,7 +773,6 @@ _p9k_left_prompt_segment() {
|
||||||
|
|
||||||
p+='${${_p9k_e:#00}:+${${_p9k_t[$_p9k_n]/'$ss'/$_p9k_ss}/'$s'/$_p9k_s}'
|
p+='${${_p9k_e:#00}:+${${_p9k_t[$_p9k_n]/'$ss'/$_p9k_ss}/'$s'/$_p9k_s}'
|
||||||
|
|
||||||
[[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale
|
|
||||||
_p9k_param $1 ICON_BEFORE_CONTENT ''
|
_p9k_param $1 ICON_BEFORE_CONTENT ''
|
||||||
if [[ $_p9k_ret != false ]]; then
|
if [[ $_p9k_ret != false ]]; then
|
||||||
_p9k_param $1 PREFIX ''
|
_p9k_param $1 PREFIX ''
|
||||||
|
@ -988,7 +993,6 @@ _p9k_right_prompt_segment() {
|
||||||
|
|
||||||
p+='${${_p9k_e:#00}:+${_p9k_t[$_p9k_n]/'$w'/$_p9k_w}'
|
p+='${${_p9k_e:#00}:+${_p9k_t[$_p9k_n]/'$w'/$_p9k_w}'
|
||||||
|
|
||||||
[[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale
|
|
||||||
_p9k_param $1 ICON_BEFORE_CONTENT ''
|
_p9k_param $1 ICON_BEFORE_CONTENT ''
|
||||||
if [[ $_p9k_ret != true ]]; then
|
if [[ $_p9k_ret != true ]]; then
|
||||||
_p9k_param $1 PREFIX ''
|
_p9k_param $1 PREFIX ''
|
||||||
|
@ -1503,7 +1507,6 @@ prompt_context() {
|
||||||
if [[ -z $text ]]; then
|
if [[ -z $text ]]; then
|
||||||
local var=_POWERLEVEL9K_CONTEXT_${state}_TEMPLATE
|
local var=_POWERLEVEL9K_CONTEXT_${state}_TEMPLATE
|
||||||
if (( $+parameters[$var] )); then
|
if (( $+parameters[$var] )); then
|
||||||
[[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale
|
|
||||||
text=${(P)var}
|
text=${(P)var}
|
||||||
text=${(g::)text}
|
text=${(g::)text}
|
||||||
else
|
else
|
||||||
|
@ -1677,7 +1680,6 @@ prompt_dir() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local -i fake_first=0 expand=0
|
local -i fake_first=0 expand=0
|
||||||
[[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale
|
|
||||||
local delim=${_POWERLEVEL9K_SHORTEN_DELIMITER-$'\u2026'}
|
local delim=${_POWERLEVEL9K_SHORTEN_DELIMITER-$'\u2026'}
|
||||||
local -i shortenlen=${_POWERLEVEL9K_SHORTEN_DIR_LENGTH:--1}
|
local -i shortenlen=${_POWERLEVEL9K_SHORTEN_DIR_LENGTH:--1}
|
||||||
|
|
||||||
|
@ -4804,7 +4806,7 @@ _p9k_dump_instant_prompt() {
|
||||||
local prompt_dir=${(q)prompt_dir}
|
local prompt_dir=${(q)prompt_dir}
|
||||||
zmodload zsh/langinfo
|
zmodload zsh/langinfo
|
||||||
if [[ \${langinfo[CODESET]:-} != (utf|UTF)(-|)8 ]]; then
|
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}}
|
local LC_ALL=\${lc:-\${\${(@M)\$(locale -a 2>/dev/null):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8}}
|
||||||
fi"
|
fi"
|
||||||
>&$fd print -r -- '
|
>&$fd print -r -- '
|
||||||
|
@ -5417,6 +5419,11 @@ _p9k_precmd_impl() {
|
||||||
|
|
||||||
(( __p9k_enabled )) || return
|
(( __p9k_enabled )) || return
|
||||||
|
|
||||||
|
if (( ! $+_p9k__locale )); then
|
||||||
|
_p9k_init_locale
|
||||||
|
[[ -z $_p9k__locale ]] || local LC_ALL=$_p9k__locale
|
||||||
|
fi
|
||||||
|
|
||||||
if ! zle || [[ -z $_p9k__param_sig ]]; then
|
if ! zle || [[ -z $_p9k__param_sig ]]; then
|
||||||
if zle; then
|
if zle; then
|
||||||
__p9k_new_status=0
|
__p9k_new_status=0
|
||||||
|
@ -5562,6 +5569,15 @@ function _p9k_prompt_overflow_bug() {
|
||||||
is-at-least 5.5 && ! is-at-least 5.7.2
|
is-at-least 5.5 && ! is-at-least 5.7.2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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}
|
||||||
|
else
|
||||||
|
typeset -g _p9k__locale=
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
typeset -g _p9k__param_pat
|
typeset -g _p9k__param_pat
|
||||||
typeset -g _p9k__param_sig
|
typeset -g _p9k__param_sig
|
||||||
|
|
||||||
|
@ -6289,7 +6305,6 @@ _p9k_build_gap_post() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_p9k_init_lines() {
|
_p9k_init_lines() {
|
||||||
[[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale
|
|
||||||
local -a left_segments=($_POWERLEVEL9K_LEFT_PROMPT_ELEMENTS)
|
local -a left_segments=($_POWERLEVEL9K_LEFT_PROMPT_ELEMENTS)
|
||||||
local -a right_segments=($_POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS)
|
local -a right_segments=($_POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS)
|
||||||
|
|
||||||
|
@ -6586,7 +6601,7 @@ _p9k_must_init() {
|
||||||
[[ $sig == $_p9k__param_sig ]] && return 1
|
[[ $sig == $_p9k__param_sig ]] && return 1
|
||||||
_p9k_deinit
|
_p9k_deinit
|
||||||
fi
|
fi
|
||||||
_p9k__param_pat=$'v36\1'${ZSH_VERSION}$'\1'${ZSH_PATCHLEVEL}$'\1'
|
_p9k__param_pat=$'v37\1'${ZSH_VERSION}$'\1'${ZSH_PATCHLEVEL}$'\1'
|
||||||
_p9k__param_pat+=$'${#parameters[(I)POWERLEVEL9K_*]}\1${(%):-%n%#}\1$GITSTATUS_LOG_LEVEL\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+=$'$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'
|
_p9k__param_pat+=$'$DEFAULT_USER\1${ZLE_RPROMPT_INDENT:-1}\1$P9K_SSH\1$__p9k_ksh_arrays'
|
||||||
|
@ -6748,7 +6763,6 @@ function _p9k_init_cacheable() {
|
||||||
|
|
||||||
if _p9k_segment_in_use dir; then
|
if _p9k_segment_in_use dir; then
|
||||||
if (( $+_POWERLEVEL9K_DIR_CLASSES )); then
|
if (( $+_POWERLEVEL9K_DIR_CLASSES )); then
|
||||||
[[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale
|
|
||||||
local -i i=3
|
local -i i=3
|
||||||
for ((; i <= $#_POWERLEVEL9K_DIR_CLASSES; i+=3)); do
|
for ((; i <= $#_POWERLEVEL9K_DIR_CLASSES; i+=3)); do
|
||||||
_POWERLEVEL9K_DIR_CLASSES[i]=${(g::)_POWERLEVEL9K_DIR_CLASSES[i]}
|
_POWERLEVEL9K_DIR_CLASSES[i]=${(g::)_POWERLEVEL9K_DIR_CLASSES[i]}
|
||||||
|
|
|
@ -1,10 +1,3 @@
|
||||||
zmodload zsh/langinfo
|
|
||||||
if [[ ${langinfo[CODESET]:-} != (utf|UTF)(-|)8 ]]; then
|
|
||||||
local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8}
|
|
||||||
fi
|
|
||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv b:zf_rm
|
|
||||||
|
|
||||||
local -i force=0
|
local -i force=0
|
||||||
|
|
||||||
local opt
|
local opt
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
local -a match mbegin mend reply
|
local -a match mbegin mend reply
|
||||||
local -i MBEGIN MEND OPTIND
|
local -i MBEGIN MEND OPTIND
|
||||||
local MATCH REPLY OPTARG IFS=$'\'' \t\n\0'\''
|
local MATCH REPLY OPTARG IFS=$'\'' \t\n\0'\''
|
||||||
[[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale'
|
[[ -z $_p9k__locale ]] || local LC_ALL=$_p9k__locale'
|
||||||
|
|
||||||
() {
|
() {
|
||||||
eval "$__p9k_intro"
|
eval "$__p9k_intro"
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
if [[ $__p9k_dump_file != $__p9k_instant_prompt_dump_file ]] && (( ! $+functions[_p9k_preinit] )) && source $__p9k_dump_file 2>/dev/null && (( $+functions[_p9k_preinit] )); then
|
if [[ $__p9k_dump_file != $__p9k_instant_prompt_dump_file ]] && (( ! $+functions[_p9k_preinit] )) && source $__p9k_dump_file 2>/dev/null && (( $+functions[_p9k_preinit] )); then
|
||||||
_p9k_preinit
|
_p9k_preinit
|
||||||
fi
|
fi
|
||||||
typeset -gr __p9k_sourced=4
|
typeset -gr __p9k_sourced=5
|
||||||
if [[ -w $__p9k_root_dir && -w $__p9k_root_dir/internal && -w $__p9k_root_dir/gitstatus && ${(%):-%#} == % ]]; then
|
if [[ -w $__p9k_root_dir && -w $__p9k_root_dir/internal && -w $__p9k_root_dir/gitstatus && ${(%):-%#} == % ]]; then
|
||||||
local f
|
local f
|
||||||
for f in $__p9k_root_dir/{powerlevel9k.zsh-theme,powerlevel10k.zsh-theme,internal/p10k.zsh,internal/icons.zsh,internal/configure.zsh,internal/worker.zsh,internal/parser.zsh,gitstatus/gitstatus.plugin.zsh}; do
|
for f in $__p9k_root_dir/{powerlevel9k.zsh-theme,powerlevel10k.zsh-theme,internal/p10k.zsh,internal/icons.zsh,internal/configure.zsh,internal/worker.zsh,internal/parser.zsh,gitstatus/gitstatus.plugin.zsh}; do
|
||||||
|
|
Loading…
Reference in a new issue