mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-12-24 16:11:57 +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() {
|
||||
[[ $+_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
|
||||
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
|
||||
local s=
|
||||
|
@ -614,7 +608,6 @@ function _p9k_init_icons() {
|
|||
# Sadly, this is a part of public API. Its use is emphatically discouraged.
|
||||
function _p9k_print_icon() {
|
||||
_p9k_init_icons
|
||||
[[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale
|
||||
local icon_name=$1
|
||||
local var_name=POWERLEVEL9K_${icon_name}
|
||||
if [[ -n "${(tP)var_name}" ]]; then
|
||||
|
@ -631,7 +624,6 @@ function _p9k_print_icon() {
|
|||
# overrides into account.
|
||||
function _p9k_get_icon_names() {
|
||||
_p9k_init_icons
|
||||
[[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale
|
||||
# Iterate over a ordered list of keys of the icons array
|
||||
for key in ${(@kon)icons}; do
|
||||
echo -n "POWERLEVEL9K_$key: "
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
if [[ $__p9k_sourced != 4 ]]; then
|
||||
if [[ $__p9k_sourced != 5 ]]; then
|
||||
>&2 print -P ""
|
||||
>&2 print -P "[%F{1}ERROR%f]: Corrupted powerlevel10k installation."
|
||||
>&2 print -P ""
|
||||
|
@ -140,6 +140,10 @@ function getColorCode() {
|
|||
# Sadly, this is a part of public API. Its use is emphatically discouraged.
|
||||
function print_icon() {
|
||||
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"
|
||||
_p9k_print_icon "$@"
|
||||
}
|
||||
|
@ -151,6 +155,10 @@ function print_icon() {
|
|||
# overrides into account.
|
||||
function get_icon_names() {
|
||||
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"
|
||||
_p9k_get_icon_names "$@"
|
||||
}
|
||||
|
@ -188,7 +196,6 @@ function _p9k_declare() {
|
|||
(( set )) && typeset -g _$2=${(P)2} || typeset -g _$2=$3
|
||||
;;
|
||||
-e)
|
||||
[[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale
|
||||
if (( set )); then
|
||||
local v=${(P)2}
|
||||
typeset -g _$2=${(g::)v}
|
||||
|
@ -529,7 +536,6 @@ _p9k_get_icon() {
|
|||
if [[ $_p9k_ret == $'\1'* ]]; then
|
||||
_p9k_ret=${_p9k_ret[2,-1]}
|
||||
else
|
||||
[[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale
|
||||
_p9k_ret=${(g::)_p9k_ret}
|
||||
[[ $_p9k_ret != $'\b'? ]] || _p9k_ret="%{$_p9k_ret%}" # penance for past sins
|
||||
fi
|
||||
|
@ -767,7 +773,6 @@ _p9k_left_prompt_segment() {
|
|||
|
||||
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 ''
|
||||
if [[ $_p9k_ret != false ]]; then
|
||||
_p9k_param $1 PREFIX ''
|
||||
|
@ -988,7 +993,6 @@ _p9k_right_prompt_segment() {
|
|||
|
||||
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 ''
|
||||
if [[ $_p9k_ret != true ]]; then
|
||||
_p9k_param $1 PREFIX ''
|
||||
|
@ -1503,7 +1507,6 @@ prompt_context() {
|
|||
if [[ -z $text ]]; then
|
||||
local var=_POWERLEVEL9K_CONTEXT_${state}_TEMPLATE
|
||||
if (( $+parameters[$var] )); then
|
||||
[[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale
|
||||
text=${(P)var}
|
||||
text=${(g::)text}
|
||||
else
|
||||
|
@ -1677,7 +1680,6 @@ prompt_dir() {
|
|||
fi
|
||||
|
||||
local -i fake_first=0 expand=0
|
||||
[[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale
|
||||
local delim=${_POWERLEVEL9K_SHORTEN_DELIMITER-$'\u2026'}
|
||||
local -i shortenlen=${_POWERLEVEL9K_SHORTEN_DIR_LENGTH:--1}
|
||||
|
||||
|
@ -4804,7 +4806,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 -- '
|
||||
|
@ -5417,6 +5419,11 @@ _p9k_precmd_impl() {
|
|||
|
||||
(( __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; then
|
||||
__p9k_new_status=0
|
||||
|
@ -5562,6 +5569,15 @@ function _p9k_prompt_overflow_bug() {
|
|||
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_sig
|
||||
|
||||
|
@ -6289,7 +6305,6 @@ _p9k_build_gap_post() {
|
|||
}
|
||||
|
||||
_p9k_init_lines() {
|
||||
[[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale
|
||||
local -a left_segments=($_POWERLEVEL9K_LEFT_PROMPT_ELEMENTS)
|
||||
local -a right_segments=($_POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS)
|
||||
|
||||
|
@ -6586,7 +6601,7 @@ _p9k_must_init() {
|
|||
[[ $sig == $_p9k__param_sig ]] && return 1
|
||||
_p9k_deinit
|
||||
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+=$'$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'
|
||||
|
@ -6748,7 +6763,6 @@ function _p9k_init_cacheable() {
|
|||
|
||||
if _p9k_segment_in_use dir; then
|
||||
if (( $+_POWERLEVEL9K_DIR_CLASSES )); then
|
||||
[[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale
|
||||
local -i i=3
|
||||
for ((; i <= $#_POWERLEVEL9K_DIR_CLASSES; i+=3)); do
|
||||
_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 opt
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
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'
|
||||
|
||||
() {
|
||||
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
|
||||
_p9k_preinit
|
||||
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
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue