diff options
author | Ben Hilburn <bhilburn@gmail.com> | 2015-12-13 03:23:04 +0300 |
---|---|---|
committer | Ben Hilburn <bhilburn@gmail.com> | 2015-12-13 03:23:04 +0300 |
commit | 0059f9a0668b21ae358c7e8bdce6c3905f70152b (patch) | |
tree | 86e297fe0a8872db4ce29124d0153ed8de192cd3 /powerlevel9k.zsh-theme | |
parent | df153db93b93f8a134adbace1a2409a25ec5f1d9 (diff) | |
parent | 8c71a28a77a3e2edebaaddd6245534f9f4514aaa (diff) |
Merge pull request #154 from dritter/hotfix/utility_function_loading
Try to fetch the utility function path automatically
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-x | powerlevel9k.zsh-theme | 29 |
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)" |