aboutsummaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2019-06-01 23:54:32 +0300
committerromkatv <roman.perepelitsa@gmail.com>2019-06-01 23:54:32 +0300
commit5e72d3ca80ef05b8078850992f6c6680a39c5a6e (patch)
tree6b41176bdf498c6b8d1668b08cb32d0367c15602 /powerlevel9k.zsh-theme
parent99bc7f3c7fa54c0eb458537740bbda231c6cf869 (diff)
move source guard to the outer script
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme64
1 files changed, 38 insertions, 26 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 97505a6c..033f86d3 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -20,32 +20,44 @@
#zstyle ':vcs_info:*+*:*' debug true
#set -o xtrace
-'builtin' 'typeset' "_p9k_aliases=$(
- 'builtin' 'alias' '-rL'
- 'builtin' 'alias' '-gL'
- 'builtin' 'alias' '-sL')"
-
-'builtin' 'unalias' '-m' '*'
-
-_p9k_installation_dir=''
-
-if [[ -n $POWERLEVEL9K_INSTALLATION_DIR ]]; then
- _p9k_installation_dir=${POWERLEVEL9K_INSTALLATION_DIR:A}
-else
- if [[ ${(%):-%N} == '(eval)' ]]; then
- if [[ $0 == '-antigen-load' && -r powerlevel9k.zsh-theme ]]; then
- # Antigen uses eval to load things so it can change the plugin (!!)
- # https://github.com/zsh-users/antigen/issues/581
- _p9k_installation_dir=$PWD
- else
- >&2 print -P '%F{red}[ERROR]%f Powerlevel10k cannot figure out its installation directory.'
- >&2 print -P 'Please set %F{green}POWERLEVEL9K_INSTALLATION_DIR.%f'
+() {
+ 'builtin' 'emulate' '-L' 'zsh'
+
+ 'builtin' 'local' "_p9k_aliases=$(
+ 'builtin' 'alias' '-rL'
+ 'builtin' 'alias' '-gL'
+ 'builtin' 'alias' '-sL')"
+
+ 'builtin' 'unalias' '-m' '*'
+
+ {
+ if (( $+_p9k_sourced )); then
+ prompt_powerlevel9k_setup
+ return
fi
- else
- _p9k_installation_dir=${${(%):-%x}:A:h}
- fi
-fi
+ typeset -gr _p9k_sourced=1
+ typeset -g _p9k_installation_dir=''
-[[ -n $_p9k_installation_dir ]] && source $_p9k_installation_dir/internal/p10k.zsh
+ if [[ -n $POWERLEVEL9K_INSTALLATION_DIR ]]; then
+ _p9k_installation_dir=${POWERLEVEL9K_INSTALLATION_DIR:A}
+ else
+ if [[ ${(%):-%N} == '(eval)' ]]; then
+ if [[ $0 == '-antigen-load' && -r powerlevel9k.zsh-theme ]]; then
+ # Antigen uses eval to load things so it can change the plugin (!!)
+ # https://github.com/zsh-users/antigen/issues/581
+ _p9k_installation_dir=$PWD
+ else
+ >&2 print -P '%F{red}[ERROR]%f Powerlevel10k cannot figure out its installation directory.'
+ >&2 print -P 'Please set %F{green}POWERLEVEL9K_INSTALLATION_DIR.%f'
+ return 1
+ fi
+ else
+ _p9k_installation_dir=${${(%):-%x}:A:h}
+ fi
+ fi
-eval "$_p9k_aliases"
+ source $_p9k_installation_dir/internal/p10k.zsh
+ } always {
+ eval "$_p9k_aliases"
+ }
+}