mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-22 04:10:07 +00:00
more robust zcompile
This commit is contained in:
parent
e5f2d39a16
commit
d9da275e9e
2 changed files with 53 additions and 25 deletions
|
@ -3873,7 +3873,7 @@ function _p9k_read_pyenv_like_version_file() {
|
||||||
else
|
else
|
||||||
local fd content
|
local fd content
|
||||||
{
|
{
|
||||||
{ sysopen -r -u fd $1 && sysread -i $fd -s 1024 content } 2>/dev/null
|
{ sysopen -r -u fd -- $1 && sysread -i $fd -s 1024 content } 2>/dev/null
|
||||||
} always {
|
} always {
|
||||||
[[ -n $fd ]] && exec {fd}>&-
|
[[ -n $fd ]] && exec {fd}>&-
|
||||||
}
|
}
|
||||||
|
@ -5161,7 +5161,7 @@ _p9k_dump_instant_prompt() {
|
||||||
if [[ ! -e $root_file ]]; then
|
if [[ ! -e $root_file ]]; then
|
||||||
local tmp=$root_file.tmp.$$
|
local tmp=$root_file.tmp.$$
|
||||||
local -i fd
|
local -i fd
|
||||||
sysopen -a -o creat,trunc -u fd $tmp || return
|
sysopen -a -m 600 -o creat,trunc -u fd -- $tmp || return
|
||||||
{
|
{
|
||||||
[[ $TERM_PROGRAM == Hyper ]] && local hyper='==' || local hyper='!='
|
[[ $TERM_PROGRAM == Hyper ]] && local hyper='==' || local hyper='!='
|
||||||
local -a display_v=("${_p9k__display_v[@]}")
|
local -a display_v=("${_p9k__display_v[@]}")
|
||||||
|
@ -5440,18 +5440,34 @@ _p9k_dump_instant_prompt() {
|
||||||
} always {
|
} always {
|
||||||
exec {fd}>&-
|
exec {fd}>&-
|
||||||
}
|
}
|
||||||
zf_mv -f $tmp $root_file || return
|
{
|
||||||
zcompile -R $root_file || return
|
(( ! $? )) || return
|
||||||
|
zf_mv -f $tmp $root_file || return
|
||||||
|
zcompile -R -- $tmp.zwc $root_file || return
|
||||||
|
zf_mv -f -- $tmp.zwc $root_file.zwc || return
|
||||||
|
} always {
|
||||||
|
(( $? )) && zf_rm -f -- $tmp $tmp.zwc 2>/dev/null
|
||||||
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local tmp=$prompt_file.tmp.$$
|
local tmp=$prompt_file.tmp.$$
|
||||||
zf_mv -f $prompt_file $tmp 2>/dev/null
|
zf_mv -f -- $prompt_file $tmp 2>/dev/null
|
||||||
if [[ "$(<$prompt_file)" == *$'\x1e'$_p9k__instant_prompt_sig$'\x1f'* ]] 2>/dev/null; then
|
if [[ "$(<$prompt_file)" == *$'\x1e'$_p9k__instant_prompt_sig$'\x1f'* ]] 2>/dev/null; then
|
||||||
echo -n >$tmp || return
|
echo -n >$tmp || return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
{ print -rn -- $'\x1e'$_p9k__instant_prompt_sig$'\x1f'${(pj:\x1f:)_p9k_t}$'\x1f'$_p9k__instant_prompt >>$tmp } 2>/dev/null || return
|
local -i fd
|
||||||
zf_mv -f $tmp $prompt_file 2>/dev/null || return
|
sysopen -a -m 600 -o creat -u fd -- $tmp || return
|
||||||
|
{
|
||||||
|
{
|
||||||
|
print -rnu $fd -- $'\x1e'$_p9k__instant_prompt_sig$'\x1f'${(pj:\x1f:)_p9k_t}$'\x1f'$_p9k__instant_prompt || return
|
||||||
|
} always {
|
||||||
|
exec {fd}>&-
|
||||||
|
}
|
||||||
|
zf_mv -f -- $tmp $prompt_file || return
|
||||||
|
} always {
|
||||||
|
(( $? )) && zf_rm -f -- $tmp 2>/dev/null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typeset -gi __p9k_sh_glob
|
typeset -gi __p9k_sh_glob
|
||||||
|
@ -5505,25 +5521,30 @@ _p9k_save_status() {
|
||||||
|
|
||||||
function _p9k_dump_state() {
|
function _p9k_dump_state() {
|
||||||
local dir=${__p9k_dump_file:h}
|
local dir=${__p9k_dump_file:h}
|
||||||
[[ -d $dir ]] || mkdir -p $dir || return
|
[[ -d $dir ]] || mkdir -p -- $dir || return
|
||||||
[[ -w $dir ]] || return
|
[[ -w $dir ]] || return
|
||||||
local tmp=$__p9k_dump_file.$$-$EPOCHREALTIME-$RANDOM
|
local tmp=$__p9k_dump_file.tmp.$$
|
||||||
local -i fd
|
local -i fd
|
||||||
sysopen -a -m 600 -o creat,trunc -u fd $tmp || return
|
sysopen -a -m 600 -o creat,trunc -u fd -- $tmp || return
|
||||||
{
|
{
|
||||||
typeset -g __p9k_cached_param_pat=$_p9k__param_pat
|
{
|
||||||
typeset -g __p9k_cached_param_sig=$_p9k__param_sig
|
typeset -g __p9k_cached_param_pat=$_p9k__param_pat
|
||||||
typeset -pm __p9k_cached_param_pat __p9k_cached_param_sig >&$fd || return
|
typeset -g __p9k_cached_param_sig=$_p9k__param_sig
|
||||||
unset __p9k_cached_param_pat __p9k_cached_param_sig
|
typeset -pm __p9k_cached_param_pat __p9k_cached_param_sig >&$fd || return
|
||||||
(( $+_p9k_preinit )) && { print -r -- $_p9k_preinit >&$fd || return }
|
unset __p9k_cached_param_pat __p9k_cached_param_sig
|
||||||
print -r -- '_p9k_restore_state_impl() {' >&$fd || return
|
(( $+_p9k_preinit )) && { print -r -- $_p9k_preinit >&$fd || return }
|
||||||
typeset -pm '_POWERLEVEL9K_*|_p9k_[^_]*|icons|OS|DEFAULT_COLOR|DEFAULT_COLOR_INVERTED' >&$fd || return
|
print -r -- '_p9k_restore_state_impl() {' >&$fd || return
|
||||||
print -r -- '}' >&$fd || return
|
typeset -pm '_POWERLEVEL9K_*|_p9k_[^_]*|icons|OS|DEFAULT_COLOR|DEFAULT_COLOR_INVERTED' >&$fd || return
|
||||||
|
print -r -- '}' >&$fd || return
|
||||||
|
} always {
|
||||||
|
exec {fd}>&-
|
||||||
|
}
|
||||||
|
zf_mv -f -- $tmp $__p9k_dump_file || return
|
||||||
|
zcompile -R -- $tmp.zwc $__p9k_dump_file || return
|
||||||
|
zf_mv -f -- $tmp.zwc $__p9k_dump_file.zwc || return
|
||||||
} always {
|
} always {
|
||||||
exec {fd}>&-
|
(( $? )) && zf_rm -f -- $tmp $tmp.zwc 2>/dev/null
|
||||||
}
|
}
|
||||||
zf_mv -f $tmp $__p9k_dump_file || return
|
|
||||||
zcompile -R $__p9k_dump_file
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _p9k_restore_state() {
|
function _p9k_restore_state() {
|
||||||
|
@ -6657,7 +6678,7 @@ function _p9k_wrap_widgets() {
|
||||||
${${${(f)"$(<$tmp)"}##* }:#(*\"|.*)}
|
${${${(f)"$(<$tmp)"}##* }:#(*\"|.*)}
|
||||||
)
|
)
|
||||||
} always {
|
} always {
|
||||||
zf_rm -f $tmp
|
zf_rm -f -- $tmp
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
local widget
|
local widget
|
||||||
|
@ -7827,7 +7848,7 @@ zmodload -F zsh/net/socket b:zsocket
|
||||||
zmodload -F zsh/files b:zf_mv b:zf_rm
|
zmodload -F zsh/files b:zf_mv b:zf_rm
|
||||||
|
|
||||||
if [[ $__p9k_dump_file != $__p9k_instant_prompt_dump_file && -n $__p9k_instant_prompt_dump_file ]]; then
|
if [[ $__p9k_dump_file != $__p9k_instant_prompt_dump_file && -n $__p9k_instant_prompt_dump_file ]]; then
|
||||||
zf_rm -f $__p9k_instant_prompt_dump_file 2>/dev/null
|
zf_rm -f -- $__p9k_instant_prompt_dump_file 2>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $+__p9k_instant_prompt_sourced == 1 && $__p9k_instant_prompt_sourced != $__p9k_instant_prompt_version ]]; then
|
if [[ $+__p9k_instant_prompt_sourced == 1 && $__p9k_instant_prompt_sourced != $__p9k_instant_prompt_version ]]; then
|
||||||
|
|
|
@ -44,10 +44,17 @@
|
||||||
_p9k_preinit
|
_p9k_preinit
|
||||||
fi
|
fi
|
||||||
typeset -gr __p9k_sourced=6
|
typeset -gr __p9k_sourced=6
|
||||||
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
|
||||||
[[ $f.zwc -nt $f ]] || zcompile -R $f
|
[[ $f.zwc -nt $f ]] && continue
|
||||||
|
zmodload -F zsh/files b:zf_mv b:zf_rm
|
||||||
|
local tmp=$f.tmp.$$.zwc
|
||||||
|
{
|
||||||
|
zcompile -R -- $tmp $f && zf_mv -f -- $tmp $f.zwc
|
||||||
|
} always {
|
||||||
|
(( $? )) && zf_rm -f -- $tmp
|
||||||
|
}
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
source $__p9k_root_dir/internal/p10k.zsh || true
|
source $__p9k_root_dir/internal/p10k.zsh || true
|
||||||
|
|
Loading…
Reference in a new issue