survive emulate sh; fixes #226

pull/230/head
romkatv 5 years ago
parent 5f15731c6a
commit 0067e0d4a1

@ -5,13 +5,12 @@
#
# for i in {0..255}; do print -Pn "%${i}F${(l:3::0:)i}%f " ${${(M)$((i%8)):#7}:+$'\n'}; done
if [[ -o 'aliases' ]]; then
# Temporarily disable aliases.
'builtin' 'unsetopt' 'aliases'
local p9k_classic_restore_aliases=1
else
local p9k_classic_restore_aliases=0
fi
# Temporarily change options.
local p10k_config_opts=()
[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases')
[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob')
[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand')
'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand'
() {
emulate -L zsh
@ -329,16 +328,16 @@ fi
vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F'${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}
# If local branch name is at most 32 characters long, show it in full.
# This is the equivalent of POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=32.
vcs+='${${${$(($#VCS_STATUS_LOCAL_BRANCH<=32)):#0}:+${VCS_STATUS_LOCAL_BRANCH//\%/%%}}'
vcs+='${${${$(( ${#VCS_STATUS_LOCAL_BRANCH}<=32 )):#0}:+${VCS_STATUS_LOCAL_BRANCH//\%/%%}}'
# If local branch name is over 32 characters long, show the first 12 … the last 12. The same as
# POWERLEVEL9K_VCS_SHORTEN_LENGTH=12 with POWERLEVEL9K_VCS_SHORTEN_STRATEGY=truncate_middle.
vcs+=':-${VCS_STATUS_LOCAL_BRANCH[1,12]//\%/%%}%28F…%76F${VCS_STATUS_LOCAL_BRANCH[-12,-1]//\%/%%}}}'
vcs+=':-${${VCS_STATUS_LOCAL_BRANCH:0:12}//\%/%%}%28F…%76F${${VCS_STATUS_LOCAL_BRANCH: -12}//\%/%%}}}'
# '@72f5c8a' if not on a branch.
vcs+=':-%248F@%76F${VCS_STATUS_COMMIT[1,8]}}'
vcs+=':-%f@%76F${VCS_STATUS_COMMIT:0:8}}'
# ':master' if the tracking branch name differs from local branch.
vcs+='${${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH}:+%248F:%76F${VCS_STATUS_REMOTE_BRANCH//\%/%%}}'
vcs+='${${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH}:+%f:%76F${VCS_STATUS_REMOTE_BRANCH//\%/%%}}'
# '#tag' if on a tag.
vcs+='${VCS_STATUS_TAG:+%248F#%76F${VCS_STATUS_TAG//\%/%%}}'
vcs+='${VCS_STATUS_TAG:+%f#%76F${VCS_STATUS_TAG//\%/%%}}'
# ⇣42 if behind the remote.
vcs+='${${VCS_STATUS_COMMITS_BEHIND:#0}:+ %76F⇣${VCS_STATUS_COMMITS_BEHIND}}'
# ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42.
@ -745,5 +744,5 @@ fi
typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}'
}
(( ! p9k_classic_restore_aliases )) || setopt aliases
'builtin' 'unset' 'p9k_classic_restore_aliases'
setopt ${p10k_config_opts[@]}
'builtin' 'unset' 'p10k_config_opts'

@ -5,13 +5,12 @@
#
# for i in {0..255}; do print -Pn "%${i}F${(l:3::0:)i}%f " ${${(M)$((i%8)):#7}:+$'\n'}; done
if [[ -o 'aliases' ]]; then
# Temporarily disable aliases.
'builtin' 'unsetopt' 'aliases'
local p10k_lean_restore_aliases=1
else
local p10k_lean_restore_aliases=0
fi
# Temporarily change options.
local p10k_config_opts=()
[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases')
[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob')
[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand')
'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand'
() {
emulate -L zsh
@ -309,12 +308,12 @@ fi
vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F'${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}
# If local branch name is at most 32 characters long, show it in full.
# This is the equivalent of POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=32.
vcs+='${${${$(($#VCS_STATUS_LOCAL_BRANCH<=32)):#0}:+${VCS_STATUS_LOCAL_BRANCH//\%/%%}}'
vcs+='${${${$(( ${#VCS_STATUS_LOCAL_BRANCH}<=32 )):#0}:+${VCS_STATUS_LOCAL_BRANCH//\%/%%}}'
# If local branch name is over 32 characters long, show the first 12 … the last 12. The same as
# POWERLEVEL9K_VCS_SHORTEN_LENGTH=12 with POWERLEVEL9K_VCS_SHORTEN_STRATEGY=truncate_middle.
vcs+=':-${VCS_STATUS_LOCAL_BRANCH[1,12]//\%/%%}%28F…%76F${VCS_STATUS_LOCAL_BRANCH[-12,-1]//\%/%%}}}'
vcs+=':-${${VCS_STATUS_LOCAL_BRANCH:0:12}//\%/%%}%28F…%76F${${VCS_STATUS_LOCAL_BRANCH: -12}//\%/%%}}}'
# '@72f5c8a' if not on a branch.
vcs+=':-%f@%76F${VCS_STATUS_COMMIT[1,8]}}'
vcs+=':-%f@%76F${VCS_STATUS_COMMIT:0:8}}'
# ':master' if the tracking branch name differs from local branch.
vcs+='${${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH}:+%f:%76F${VCS_STATUS_REMOTE_BRANCH//\%/%%}}'
# '#tag' if on a tag.
@ -724,5 +723,5 @@ fi
typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}'
}
(( ! p10k_lean_restore_aliases )) || setopt aliases
'builtin' 'unset' 'p10k_lean_restore_aliases'
setopt ${p10k_config_opts[@]}
'builtin' 'unset' 'p10k_config_opts'

@ -11,7 +11,7 @@ typeset -gr __p9k_root_dir_u=${${${(q)__p9k_root_dir}/#(#b)${(q)HOME}(|\/*)/'~'$
function _p9k_can_configure() {
emulate -L zsh
setopt extended_glob no_prompt_{bang,subst} prompt_{cr,percent,sp}
setopt extended_glob no_prompt_{bang,subst} prompt_percent
[[ $1 == '-q' ]] && local -i q=1 || local -i q=0
function $0_error() {
(( q )) || print -rP "%1F[ERROR]%f %Bp10k configure%b: $1" >&2
@ -59,7 +59,8 @@ function _p9k_can_configure() {
}
function p9k_configure() {
emulate -L zsh && setopt no_hist_expand extended_glob
emulate -L zsh
setopt no_hist_expand extended_glob
(
local p=("${(@)parameters[(I)AWESOME_*|CODEPOINT_*]}")
if (( $#p )); then

@ -540,7 +540,8 @@ function _p9k_init_icons() {
# Sadly, this is a part of public API. Its use is emphatically discouraged.
function print_icon() {
emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
emulate -L zsh
setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
_p9k_init_icons
[[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale
local icon_name=$1
@ -558,7 +559,8 @@ function print_icon() {
# otherwise "print_icon" is used, which takes the users
# overrides into account.
function get_icon_names() {
emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
emulate -L zsh
setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
_p9k_init_icons
[[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale
# Iterate over a ordered list of keys of the icons array

@ -89,7 +89,8 @@ typeset -grA __p9k_colors=(
#
# Type `getColorCode background` or `getColorCode foreground` to see the list of predefined colors.
function getColorCode() {
emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
emulate -L zsh
setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
if (( ARGC == 1 )); then
case $1 in
foreground)
@ -170,7 +171,6 @@ function _p9k_declare() {
# _p9k_prompt_length '%F{red}abc' => 3
# _p9k_prompt_length $'%{a\b%Gb%}' => 1
function _p9k_prompt_length() {
emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
local COLUMNS=1024
local -i x y=$#1 m
if (( y )); then
@ -456,7 +456,7 @@ _p9k_left_prompt_segment() {
# 4
# fi
local t=$#_p9k_t
local t=$(($#_p9k_t - __p9k_ksh_arrays))
_p9k_t+=$start_sep$style$left_space # 1
_p9k_t+=$style # 2
if [[ -n $fg_color && $fg_color == $bg_color ]]; then
@ -479,7 +479,12 @@ _p9k_left_prompt_segment() {
p+="\${_p9k_n::=}"
p+="\${\${\${_p9k_bg:-0}:#NONE}:-\${_p9k_n::=$((t+1))}}" # 1
p+="\${_p9k_n:=\${\${\$(($join)):#0}:+$((t+2))}}" # 2
if (( __p9k_sh_glob )); then
p+="\${_p9k_n:=\${\${(M)\${:-x$bg_color}:#x\$_p9k_bg}:+$((t+3))}}" # 3
p+="\${_p9k_n:=\${\${(M)\${:-x$bg_color}:#x\$${_p9k_bg:-0}}:+$((t+3))}}" # 3
else
p+="\${_p9k_n:=\${\${(M)\${:-x$bg_color}:#x(\$_p9k_bg|\${_p9k_bg:-0})}:+$((t+3))}}" # 3
fi
p+="\${_p9k_n:=$((t+4))}" # 4
_p9k_param $1 VISUAL_IDENTIFIER_EXPANSION '${P9K_VISUAL_IDENTIFIER}'
@ -666,7 +671,7 @@ _p9k_right_prompt_segment() {
# 4
# fi
local t=$#_p9k_t
local t=$(($#_p9k_t - __p9k_ksh_arrays))
_p9k_t+=$start_sep$style$left_space # 1
_p9k_t+=$w$style # 2
_p9k_t+=$w$subsep$style$left_space # 3
@ -680,7 +685,12 @@ _p9k_right_prompt_segment() {
p+="\${_p9k_n::=}"
p+="\${\${\${_p9k_bg:-0}:#NONE}:-\${_p9k_n::=$((t+1))}}" # 1
p+="\${_p9k_n:=\${\${\$(($join)):#0}:+$((t+2))}}" # 2
if (( __p9k_sh_glob )); then
p+="\${_p9k_n:=\${\${(M)\${:-x\$_p9k_bg}:#x${(b)bg_color}}:+$((t+3))}}" # 3
p+="\${_p9k_n:=\${\${(M)\${:-x\$_p9k_bg}:#x${(b)bg_color:-0}}:+$((t+3))}}" # 3
else
p+="\${_p9k_n:=\${\${(M)\${:-x\$_p9k_bg}:#x(${(b)bg_color}|${(b)bg_color:-0})}:+$((t+3))}}" # 3
fi
p+="\${_p9k_n:=$((t+4))}" # 4
_p9k_param $1 VISUAL_IDENTIFIER_EXPANSION '${P9K_VISUAL_IDENTIFIER}'
@ -2030,6 +2040,27 @@ prompt_status() {
}
prompt_prompt_char() {
if (( __p9k_sh_glob )); then
if (( _p9k_status )); then
if (( _POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE )); then
_p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${${${${${${:-$_p9k_keymap.$_p9k_zle_state}:#vicmd.*}:#vivis.*}:#vivli.*}:#*.*overwrite*}}' ''
_p9k_prompt_segment $0_ERROR_VIOWR "$_p9k_color1" 196 '' 0 '${${${${${${:-$_p9k_keymap.$_p9k_zle_state}:#vicmd.*}:#vivis.*}:#vivli.*}:#*.*insert*}}' '▶'
else
_p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${${${${_p9k_keymap:#vicmd}:#vivis}:#vivli}}' ''
fi
_p9k_prompt_segment $0_ERROR_VICMD "$_p9k_color1" 196 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' ''
_p9k_prompt_segment $0_ERROR_VIVIS "$_p9k_color1" 196 '' 0 '${$((! ${#${${${${:-$_p9k_keymap$_p9k_region_active}:#vicmd1}:#vivis?}:#vivli?}})):#0}' ''
else
if (( _POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE )); then
_p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${${${${${${:-$_p9k_keymap.$_p9k_zle_state}:#vicmd.*}:#vivis.*}:#vivli.*}:#*.*overwrite*}}' ''
_p9k_prompt_segment $0_OK_VIOWR "$_p9k_color1" 76 '' 0 '${${${${${${:-$_p9k_keymap.$_p9k_zle_state}:#vicmd.*}:#vivis.*}:#vivli.*}:#*.*insert*}}' '▶'
else
_p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${${${${_p9k_keymap:#vicmd}:#vivis}:#vivli}}' ''
fi
_p9k_prompt_segment $0_OK_VICMD "$_p9k_color1" 76 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' ''
_p9k_prompt_segment $0_OK_VIVIS "$_p9k_color1" 76 '' 0 '${$((! ${#${${${${:-$_p9k_keymap$_p9k_region_active}:#vicmd1}:#vivis?}:#vivli?}})):#0}' ''
fi
else
if (( _p9k_status )); then
if (( _POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE )); then
_p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*overwrite*)}' ''
@ -2049,6 +2080,7 @@ prompt_prompt_char() {
_p9k_prompt_segment $0_OK_VICMD "$_p9k_color1" 76 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' ''
_p9k_prompt_segment $0_OK_VIVIS "$_p9k_color1" 76 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' ''
fi
fi
}
################################################################
@ -2615,7 +2647,8 @@ function _p9k_vcs_render() {
}
function _p9k_vcs_resume() {
emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
emulate -L zsh
setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
if [[ $VCS_STATUS_RESULT == ok-async ]]; then
local latency=$((EPOCHREALTIME - _p9k_gitstatus_start_time))
@ -2726,6 +2759,25 @@ prompt_vcs() {
################################################################
# Vi Mode: show editing mode (NORMAL|INSERT|VISUAL)
prompt_vi_mode() {
if (( __p9k_sh_glob )); then
if (( $+_POWERLEVEL9K_VI_OVERWRITE_MODE_STRING )); then
if [[ -n $_POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then
_p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${${${${${${:-$_p9k_keymap.$_p9k_zle_state}:#vicmd.*}:#vivis.*}:#vivli.*}:#*.*overwrite*}}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING"
fi
_p9k_prompt_segment $0_OVERWRITE "$_p9k_color1" blue '' 0 '${${${${${${:-$_p9k_keymap.$_p9k_zle_state}:#vicmd.*}:#vivis.*}:#vivli.*}:#*.*insert*}}' "$_POWERLEVEL9K_VI_OVERWRITE_MODE_STRING"
else
if [[ -n $_POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then
_p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${${${${_p9k_keymap:#vicmd}:#vivis}:#vivli}}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING"
fi
fi
if (( $+_POWERLEVEL9K_VI_VISUAL_MODE_STRING )); then
_p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING"
_p9k_prompt_segment $0_VISUAL "$_p9k_color1" white '' 0 '${$((! ${#${${${${:-$_p9k_keymap$_p9k_region_active}:#vicmd1}:#vivis?}:#vivli?}})):#0}' "$_POWERLEVEL9K_VI_VISUAL_MODE_STRING"
else
_p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${$((! ${#${${${_p9k_keymap:#vicmd}:#vivis}:#vivli}})):#0}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING"
fi
else
if (( $+_POWERLEVEL9K_VI_OVERWRITE_MODE_STRING )); then
if [[ -n $_POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then
_p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*overwrite*)}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING"
@ -2743,6 +2795,7 @@ prompt_vi_mode() {
else
_p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${(M)_p9k_keymap:#(vicmd|vivis|vivli)}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING"
fi
fi
}
################################################################
@ -3203,11 +3256,12 @@ function _p9k_update_prompt() {
_p9k_refresh_reason=$1
_p9k_set_prompt
_p9k_refresh_reason=''
zle && zle .reset-prompt && zle -R
_p9k_reset_prompt
}
powerlevel9k_refresh_prompt_inplace() {
emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
emulate -L zsh
setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
(( __p9k_enabled )) || return
_p9k_refresh_reason=precmd
_p9k_set_prompt
@ -3216,11 +3270,12 @@ powerlevel9k_refresh_prompt_inplace() {
p9k_refresh_prompt_inplace() { powerlevel9k_refresh_prompt_inplace }
typeset -gi __p9k_sh_glob
typeset -gi __p9k_ksh_arrays
typeset -gi __p9k_new_status
typeset -ga __p9k_new_pipestatus
_p9k_save_status() {
emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
local -i pipe
if (( !$+_p9k_line_finished )); then
: # SIGINT
@ -3264,9 +3319,11 @@ _p9k_save_status() {
fi
}
_p9k_precmd() {
__p9k_new_status=$?
__p9k_new_pipestatus=($pipestatus)
_p9k_precmd_impl() {
emulate -L zsh
setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
(( __p9k_enabled )) || return
if ! zle; then
print -rn "${_p9k_prompt_newline:-}"
@ -3317,23 +3374,38 @@ _p9k_precmd() {
_p9k_zle_state=insert
fi
_p9k_refresh_reason=precmd
_p9k_set_prompt
_p9k_refresh_reason=''
}
_p9k_precmd() {
__p9k_new_status=$?
__p9k_new_pipestatus=($pipestatus)
[[ -o ksh_arrays ]] && __p9k_ksh_arrays=1 || __p9k_ksh_arrays=0
[[ -o sh_glob ]] && __p9k_sh_glob=1 || __p9k_sh_glob=0
unsetopt localoptions
prompt_opts=(percent subst)
[[ ! -o prompt_sp ]] || prompt_opts+=sp
[[ ! -o prompt_cr ]] || prompt_opts+=cr
setopt nopromptbang prompt{percent,subst}
setopt nopromptbang prompt_percent prompt_subst
powerlevel9k_refresh_prompt_inplace
_p9k_precmd_impl
}
function _p9k_zle_keymap_select() {
emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
function _p9k_reset_prompt() {
(( __p9k_ksh_arrays )) && setopt ksh_arrays
(( __p9k_sh_glob )) && setopt sh_glob
zle && zle .reset-prompt && zle -R
}
function _p9k_zle_keymap_select() {
_p9k_reset_prompt
}
function _p9k_zle_state_changed() {
emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
zle && zle .reset-prompt && zle -R
_p9k_reset_prompt
}
_p9k_deinit_async_pump() {
@ -3364,7 +3436,8 @@ _p9k_deinit_async_pump() {
}
function _p9k_on_async_message() {
emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
emulate -L zsh
setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
(( ARGC == 1 )) || return
local msg='' IFS=''
while read -r -t -u $1 msg; do
@ -3373,7 +3446,7 @@ function _p9k_on_async_message() {
msg=
done
_p9k_async_pump_line+=$msg
[[ $__p9k_enabled == 1 && $1 == $_p9k_async_pump_fd ]] && zle && zle .reset-prompt && zle -R
[[ $__p9k_enabled == 1 && $1 == $_p9k_async_pump_fd ]] && _p9k_reset_prompt
}
function _p9k_async_pump() {
@ -3440,7 +3513,8 @@ function _p9k_async_pump() {
}
function _p9k_kill_async_pump() {
emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
emulate -L zsh
setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
if [[ $ZSH_SUBSHELL == $_p9k_async_pump_subshell && $$ == $_p9k_async_pump_shell_pid ]]; then
_p9k_deinit_async_pump
fi
@ -3880,7 +3954,9 @@ _p9k_wrap_zle_widget() {
local wrapper=_p9k_wrapper_$widget_$hook
eval "function ${(q)wrapper}() {
${(q)hook} \"\$@\"
emulate -L zsh
setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
(( __p9k_enabled )) && ${(q)hook} \"\$@\"
(( \$+widgets[${(q)orig}] )) && zle ${(q)orig} -- \"\$@\"
}"
@ -3888,22 +3964,18 @@ _p9k_wrap_zle_widget() {
}
function _p9k_zle_line_finish() {
(( __p9k_enabled )) || return
_p9k_line_finished=
if (( _p9k_reset_on_line_finish )); then
emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
zle && zle .reset-prompt && zle -R
_p9k_reset_prompt
fi
}
function _p9k_zle_line_pre_redraw() {
(( __p9k_enabled )) || return
[[ ${KEYMAP:-} == vicmd ]] || return 0
local region=${${REGION_ACTIVE:-0}/2/1}
[[ $region != $_p9k_region_active ]] || return 0
emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
_p9k_region_active=$region
zle && zle .reset-prompt && zle -R
_p9k_reset_prompt
}
prompt__p9k_internal_nothing() {
@ -3938,7 +4010,11 @@ _p9k_build_gap_post() {
_p9k_ret+='${:-"'$exp'"}'
style=1
fi
_p9k_ret+=$'$_p9k_rprompt$_p9k_t[$((1+!_p9k_ind))]}:-\n}'
if (( __p9k_ksh_arrays )); then
_p9k_ret+=$'$_p9k_rprompt${_p9k_t[$((!_p9k_ind))]}}:-\n}'
else
_p9k_ret+=$'$_p9k_rprompt${_p9k_t[$((1+!_p9k_ind))]}}:-\n}'
fi
[[ -n $style ]] && _p9k_ret+='%b%k%f'
}
@ -4128,7 +4204,11 @@ _p9k_init_prompt() {
[[ $ruler_char == '.' ]] && local sep=',' || local sep='.'
local ruler_len='${$((_p9k_clm-_p9k_ind))/#-*/0}'
_p9k_prompt_prefix_left+="\${(pl$sep$ruler_len$sep$sep${(q)ruler_char}$sep)}%k%f"
_p9k_prompt_prefix_left+='$_p9k_t[$((1+!_p9k_ind))]'
if (( __p9k_ksh_arrays )); then
_p9k_prompt_prefix_left+='${_p9k_t[$((!_p9k_ind))]}'
else
_p9k_prompt_prefix_left+='${_p9k_t[$((1+!_p9k_ind))]}'
fi
else
print -rP -- "%F{red}WARNING!%f %BPOWERLEVEL9K_RULER_CHAR%b is not one character long. Ruler won't be rendered."
print -rP -- "Either change the value of %BPOWERLEVEL9K_RULER_CHAR%b or set %BPOWERLEVEL9K_SHOW_RULER=false%b to"
@ -4179,12 +4259,11 @@ _p9k_init_ssh() {
}
_p9k_must_init() {
emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
local -a param_keys=(
${(o)parameters[(I)(POWERLEVEL9K_*|GITSTATUS_LOG_LEVEL|GITSTATUS_ENABLE_LOGGING|GITSTATUS_DAEMON|GITSTATUS_NUM_THREADS|DEFAULT_USER|ZLE_RPROMPT_INDENT)]})
local IFS param_sig
IFS=$'\1' param_sig="${(@)param_keys:/(#b)(*)/$match[1]=\$$match[1]}"
IFS=$'\2' eval "param_sig=x\"$param_sig\""
IFS=$'\2' eval "param_sig=$__p9k_ksh_arrays$__p9k_sh_glob\"$param_sig\""
[[ -o transient_rprompt ]] && param_sig+=t
[[ $param_sig == $_p9k_param_sig ]] && return 1
[[ -n $_p9k_param_sig ]] && _p9k_deinit
@ -4198,8 +4277,6 @@ function _p9k_set_os() {
}
_p9k_init() {
emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
_p9k_init_icons
_p9k_init_vars
_p9k_init_params
@ -4433,7 +4510,8 @@ typeset -gi __p9k_enabled=0
typeset -gi __p9k_configured=0
prompt_powerlevel9k_setup() {
emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
emulate -L zsh
setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
prompt_powerlevel9k_teardown
__p9k_enabled=1
add-zsh-hook preexec _p9k_preexec
@ -4441,7 +4519,8 @@ prompt_powerlevel9k_setup() {
}
prompt_powerlevel9k_teardown() {
emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
emulate -L zsh
setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst}
add-zsh-hook -D precmd '(_p9k_|powerlevel9k_)*'
add-zsh-hook -D preexec '(_p9k_|powerlevel9k_)*'
PROMPT='%m%# '

@ -4,7 +4,7 @@ emulate -L zsh
setopt noaliases
() {
setopt extended_glob no_prompt_{bang,subst} prompt_{cr,percent,sp} typeset_silent
setopt extended_glob no_prompt_{bang,subst} prompt_percent typeset_silent
zmodload zsh/langinfo
if [[ ${langinfo[CODESET]:-} != (utf|UTF)(-|)8 ]]; then
local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8}

@ -17,11 +17,11 @@ else
local __p9k_restore_aliases=0
fi
typeset -g __p9k_root_dir=${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}}
typeset -g __p9k_root_dir="${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}}"
() {
emulate -L zsh
setopt no_hist_expand extended_glob no_prompt_{bang,subst} prompt_{cr,percent,sp}
setopt no_hist_expand extended_glob no_prompt_bang no_prompt_subst prompt_percent
if (( $+__p9k_sourced )); then
prompt_powerlevel9k_setup
return

Loading…
Cancel
Save