mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-11 00:00:06 +00:00
Merge pull request #154 from dritter/hotfix/utility_function_loading
Try to fetch the utility function path automatically
This commit is contained in:
commit
0059f9a066
1 changed files with 25 additions and 4 deletions
|
@ -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)"
|
||||
|
||||
|
|
Loading…
Reference in a new issue