Check and set prompt_opts when not using promptinit (#277)
The `prompt_opts` array only has an effect when the theme is loaded via promptinit (`prompt pure`). Previously they were not set when pure was loaded via `source /path/to/pure.zsh` as is the case with e.g. antigen, antibody, etc. This commit attempts to detect whenever pure is not autoloaded via promptinit and manually sets the options in `prompt_opts`. Fixes #276.
This commit is contained in:
committed by
GitHub
parent
e06fd4af63
commit
17e81f37ce
11
pure.zsh
11
pure.zsh
@@ -342,12 +342,21 @@ prompt_pure_async_callback() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
prompt_pure_setup() {
|
prompt_pure_setup() {
|
||||||
|
local autoload_name=$1; shift
|
||||||
|
|
||||||
# prevent percentage showing up
|
# prevent percentage showing up
|
||||||
# if output doesn't end with a newline
|
# if output doesn't end with a newline
|
||||||
export PROMPT_EOL_MARK=''
|
export PROMPT_EOL_MARK=''
|
||||||
|
|
||||||
prompt_opts=(subst percent)
|
prompt_opts=(subst percent)
|
||||||
|
|
||||||
|
# if autoload_name or eval context differ, pure wasn't autoloaded via
|
||||||
|
# promptinit and we need to take care of setting the options ourselves
|
||||||
|
if [[ $autoload_name != prompt_pure_setup ]] || [[ $zsh_eval_context[-2] != loadautofunc ]]; then
|
||||||
|
# borrowed from `promptinit`, set the pure prompt options
|
||||||
|
setopt noprompt{bang,cr,percent,subst} "prompt${^prompt_opts[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
zmodload zsh/datetime
|
zmodload zsh/datetime
|
||||||
zmodload zsh/zle
|
zmodload zsh/zle
|
||||||
zmodload zsh/parameter
|
zmodload zsh/parameter
|
||||||
@@ -385,4 +394,4 @@ prompt_pure_setup() {
|
|||||||
PROMPT='%(?.%F{magenta}.%F{red})${PURE_PROMPT_SYMBOL:-❯}%f '
|
PROMPT='%(?.%F{magenta}.%F{red})${PURE_PROMPT_SYMBOL:-❯}%f '
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt_pure_setup "$@"
|
prompt_pure_setup "$0" "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user