aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2020-01-27 11:33:01 +0300
committerromkatv <roman.perepelitsa@gmail.com>2020-01-27 11:33:01 +0300
commit3bca7e845f6e85b7fad20e0356ca3ec14b187dd1 (patch)
tree66e0c7ac51647e663f735957cc823bea15fafdca
parentb7777bb86e0b5358f9d6d0bc81bc829f5b55eaba (diff)
detect source code corruption done by antigen and suggest resetting cache
-rw-r--r--internal/p10k.zsh26
-rw-r--r--powerlevel10k.zsh-theme4
2 files changed, 27 insertions, 3 deletions
diff --git a/internal/p10k.zsh b/internal/p10k.zsh
index 062adf74..b3a725e7 100644
--- a/internal/p10k.zsh
+++ b/internal/p10k.zsh
@@ -1,3 +1,25 @@
+if [[ $__p9k_sourced != 2 ]]; then
+ >&2 print -P ""
+ >&2 print -P "[%F{1}ERROR%f]: Corrupted powerlevel10k installation."
+ >&2 print -P ""
+ if (( ${+functions[antigen]} )); then
+ >&2 print -P "If using %Bantigen%b, run the folowing command to fix:"
+ >&2 print -P ""
+ >&2 print -P " %F{2}antigen%f reset"
+ if [[ -d ~/.antigen ]]; then
+ >&2 print -P ""
+ >&2 print -P "If it doesn't help, try this:"
+ >&2 print -P ""
+ >&2 print -P " %F{2}rm%f -rf %U~/.antigen%u"
+ fi
+ else
+ >&2 print -P "Try resetting cache in your plugin manager or"
+ >&2 print -P "reinstalling powerlevel10k from scratch."
+ fi
+ >&2 print -P ""
+ return 1
+fi
+
if ! autoload -Uz is-at-least || ! is-at-least 5.1; then
() {
>&2 echo -E "You are using ZSH version $ZSH_VERSION. The minimum required version for Powerlevel10k is 5.1."
@@ -7139,7 +7161,7 @@ fi
_p9k_do_nothing() { true; }
-prompt_powerlevel9k_setup() {
+_p9k_setup() {
(( __p9k_enabled )) && return
prompt_opts=(percent subst)
@@ -7155,6 +7177,8 @@ prompt_powerlevel9k_setup() {
typeset -ga precmd_functions=(_p9k_do_nothing $precmd_functions _p9k_precmd)
}
+prompt_powerlevel9k_setup() { _p9k_setup }
+
prompt_powerlevel9k_teardown() {
eval $__p9k_intro
add-zsh-hook -D precmd '(_p9k_|powerlevel9k_)*'
diff --git a/powerlevel10k.zsh-theme b/powerlevel10k.zsh-theme
index 57cb3502..6069543b 100644
--- a/powerlevel10k.zsh-theme
+++ b/powerlevel10k.zsh-theme
@@ -28,14 +28,14 @@
() {
eval $__p9k_intro
if (( $+__p9k_sourced )); then
- prompt_powerlevel9k_setup
+ (( $+functions[_p9k_setup] )) && _p9k_setup
return 0
fi
typeset -gr __p9k_dump_file=${XDG_CACHE_HOME:-~/.cache}/p10k-dump-${(%):-%n}.zsh
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=1
+ typeset -gr __p9k_sourced=2
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,gitstatus/gitstatus.plugin.zsh}; do