aboutsummaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme29
1 files changed, 25 insertions, 4 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 2870802b..3d2d5d2c 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -19,9 +19,30 @@
# Check if the theme was called as a function.
if [[ $(whence -w prompt_powerlevel9k_setup) =~ "function" ]]; then
- # Script is a function! We assume this to happen only in
- # prezto, as they use the zstyle-builtin to set the theme.
- 0="${ZDOTDIR:-$HOME}/.zprezto/modules/prompt/functions/prompt_powerlevel9k_setup"
+ autoload -U is-at-least
+ if is-at-least 5.0.8; then
+ # Try to find the correct path of the script.
+ 0=$(whence -v $0 | sed "s/$0 is a shell function from //")
+ elif [[ -f "${ZDOTDIR:-$HOME}/.zprezto/modules/prompt/init.zsh" ]]; then
+ # If there is an prezto installation, we assume that powerlevel9k is linked there.
+ 0="${ZDOTDIR:-$HOME}/.zprezto/modules/prompt/functions/prompt_powerlevel9k_setup"
+ else
+ # Fallback: specify an installation path!
+ if [[ -z "$POWERLEVEL9K_INSTALLATION_PATH" ]]; then
+ print -P "%F{red}We could not locate the installation path of powerlevel9k.%f"
+ print -P "Please specify by setting %F{blue}POWERLEVEL9K_INSTALLATION_PATH%f (full path incl. file name) at the very beginning of your ~/.zshrc"
+ return 1
+ elif [[ -L "$POWERLEVEL9K_INSTALLATION_PATH" ]]; then
+ # Symlink
+ 0="$POWERLEVEL9K_INSTALLATION_PATH"
+ elif [[ -f "$POWERLEVEL9K_INSTALLATION_PATH" ]]; then
+ # File
+ 0="$POWERLEVEL9K_INSTALLATION_PATH"
+ elif [[ -d "$POWERLEVEL9K_INSTALLATION_PATH" ]]; then
+ # Directory
+ 0="${POWERLEVEL9K_INSTALLATION_PATH}/powerlevel9k.zsh-theme"
+ fi
+ fi
fi
# Check if filename is a symlink.
@@ -33,7 +54,7 @@ elif [[ -f $0 ]]; then
filename="$0"
else
print -P "%F{red}Script location could not be found!%f"
- exit 1
+ return 1
fi
script_location="$(dirname $filename)"