mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-12-24 16:11:57 +00:00
better utf-8 handling
This commit is contained in:
parent
a5e9af847d
commit
e537a0ee62
5 changed files with 21 additions and 16 deletions
|
@ -16,7 +16,8 @@ fi
|
||||||
() {
|
() {
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
setopt no_unset
|
setopt no_unset
|
||||||
if [[ ${LC_ALL:-${LANG:-}} != *.(utf|UTF)(-|)8 ]]; then
|
zmodload zsh/langinfo
|
||||||
|
if [[ ${langinfo[CODESET]:-} != (utf|UTF)(-|)8 ]]; then
|
||||||
local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8}
|
local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,8 @@ fi
|
||||||
() {
|
() {
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
setopt no_unset
|
setopt no_unset
|
||||||
if [[ ${LC_ALL:-${LANG:-}} != *.(utf|UTF)(-|)8 ]]; then
|
zmodload zsh/langinfo
|
||||||
|
if [[ ${langinfo[CODESET]:-} != (utf|UTF)(-|)8 ]]; then
|
||||||
local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8}
|
local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,11 @@ typeset -gA icons
|
||||||
function _p9k_init_icons() {
|
function _p9k_init_icons() {
|
||||||
[[ $+_p9k_icon_mode == 1 && $_p9k_icon_mode == $POWERLEVEL9K_MODE ]] && return
|
[[ $+_p9k_icon_mode == 1 && $_p9k_icon_mode == $POWERLEVEL9K_MODE ]] && return
|
||||||
typeset -g _p9k_icon_mode=$POWERLEVEL9K_MODE
|
typeset -g _p9k_icon_mode=$POWERLEVEL9K_MODE
|
||||||
typeset -g _p9k_locale=${LC_ALL:-$LANG}
|
zmodload zsh/langinfo
|
||||||
if [[ $_p9k_locale != *.(utf|UTF)(-|)8 ]]; then
|
if [[ ${langinfo[CODESET]:-} != (utf|UTF)(-|)8 ]]; then
|
||||||
_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=
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case $POWERLEVEL9K_MODE in
|
case $POWERLEVEL9K_MODE in
|
||||||
|
@ -535,7 +537,7 @@ function _p9k_init_icons() {
|
||||||
function print_icon() {
|
function print_icon() {
|
||||||
emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp}
|
emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp}
|
||||||
_p9k_init_icons
|
_p9k_init_icons
|
||||||
local LC_ALL=$_p9k_locale
|
[[ -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
|
||||||
|
@ -553,7 +555,7 @@ function print_icon() {
|
||||||
function get_icon_names() {
|
function get_icon_names() {
|
||||||
emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp}
|
emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp}
|
||||||
_p9k_init_icons
|
_p9k_init_icons
|
||||||
local LC_ALL=$_p9k_locale
|
[[ -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: "
|
||||||
|
|
|
@ -147,7 +147,7 @@ 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)
|
||||||
local LC_ALL=$_p9k_locale
|
[[ -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}
|
||||||
|
@ -330,7 +330,7 @@ _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
|
||||||
local LC_ALL=$_p9k_locale
|
[[ -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
|
||||||
|
@ -551,7 +551,7 @@ _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}'
|
||||||
|
|
||||||
local LC_ALL=$_p9k_locale
|
[[ -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 ''
|
||||||
|
@ -752,7 +752,7 @@ _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}'
|
||||||
|
|
||||||
local LC_ALL=$_p9k_locale
|
[[ -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 ''
|
||||||
|
@ -1091,7 +1091,7 @@ prompt_context() {
|
||||||
if [[ -z $content ]]; then
|
if [[ -z $content ]]; then
|
||||||
local var=POWERLEVEL9K_CONTEXT_${state}_TEMPLATE
|
local var=POWERLEVEL9K_CONTEXT_${state}_TEMPLATE
|
||||||
if (( $+parameters[$var] )); then
|
if (( $+parameters[$var] )); then
|
||||||
local LC_ALL=$_p9k_locale
|
[[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale
|
||||||
content=${(P)var}
|
content=${(P)var}
|
||||||
content=${(g::)content}
|
content=${(g::)content}
|
||||||
else
|
else
|
||||||
|
@ -3570,7 +3570,7 @@ _p9k_init_params() {
|
||||||
if [[ $parameters[POWERLEVEL9K_BATTERY_STAGES] == scalar ]]; then
|
if [[ $parameters[POWERLEVEL9K_BATTERY_STAGES] == scalar ]]; then
|
||||||
_p9k_declare -e POWERLEVEL9K_BATTERY_STAGES
|
_p9k_declare -e POWERLEVEL9K_BATTERY_STAGES
|
||||||
else
|
else
|
||||||
local LC_ALL=$_p9k_locale
|
[[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale
|
||||||
_p9k_declare -a POWERLEVEL9K_BATTERY_STAGES --
|
_p9k_declare -a POWERLEVEL9K_BATTERY_STAGES --
|
||||||
_POWERLEVEL9K_BATTERY_STAGES=("${(@g::)_POWERLEVEL9K_BATTERY_STAGES}")
|
_POWERLEVEL9K_BATTERY_STAGES=("${(@g::)_POWERLEVEL9K_BATTERY_STAGES}")
|
||||||
fi
|
fi
|
||||||
|
@ -3833,7 +3833,7 @@ _p9k_build_gap_post() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_p9k_init_lines() {
|
_p9k_init_lines() {
|
||||||
local LC_ALL=$_p9k_locale
|
[[ -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)
|
||||||
|
|
||||||
|
@ -4250,7 +4250,7 @@ _p9k_init() {
|
||||||
|
|
||||||
if _p9k_segment_in_use dir; then
|
if _p9k_segment_in_use dir; then
|
||||||
if (( $+_POWERLEVEL9K_DIR_CLASSES )); then
|
if (( $+_POWERLEVEL9K_DIR_CLASSES )); then
|
||||||
local LC_ALL=$_p9k_locale
|
[[ -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]}
|
||||||
|
|
|
@ -5,7 +5,8 @@ setopt noaliases
|
||||||
|
|
||||||
() {
|
() {
|
||||||
setopt extended_glob no_prompt_{bang,subst} prompt_{cr,percent,sp}
|
setopt extended_glob no_prompt_{bang,subst} prompt_{cr,percent,sp}
|
||||||
if [[ ${LC_ALL:-$LANG} != *.(utf|UTF)(-|)8 ]]; then
|
zmodload zsh/langinfo
|
||||||
|
if [[ ${langinfo[CODESET]:-} != (utf|UTF)(-|)8 ]]; then
|
||||||
local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8}
|
local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue