From 17e81f37cef664ca304966a2bb42f15373d33fd2 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Fri, 20 Jan 2017 09:59:40 +0200 Subject: [PATCH] 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. --- pure.zsh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pure.zsh b/pure.zsh index 42f43f1..146fc34 100644 --- a/pure.zsh +++ b/pure.zsh @@ -342,12 +342,21 @@ prompt_pure_async_callback() { } prompt_pure_setup() { + local autoload_name=$1; shift + # prevent percentage showing up # if output doesn't end with a newline export PROMPT_EOL_MARK='' 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/zle zmodload zsh/parameter @@ -385,4 +394,4 @@ prompt_pure_setup() { PROMPT='%(?.%F{magenta}.%F{red})${PURE_PROMPT_SYMBOL:-❯}%f ' } -prompt_pure_setup "$@" +prompt_pure_setup "$0" "$@"