Restore prompt_subst setopt when rendering prompt (#231)

We store the user setting for `prompt_subst` before changing it in the
local scope of `prompt_pure_preprompt_render`. This allows us to restore
it when we render the real prompt (`PS1`) through `zle .redraw-prompt`.

Fixes #230.
This commit is contained in:
Mathias Fredriksson
2016-09-20 16:56:12 +03:00
committed by GitHub
parent d826130a1a
commit 5ccc336b35

View File

@@ -123,7 +123,10 @@ prompt_pure_string_length_to_var() {
}
prompt_pure_preprompt_render() {
# make sure prompt_subst is unset to prevent parameter expansion in prompt
# store the current prompt_subst setting so that it can be restored later
local prompt_subst_status=$options[prompt_subst]
# make sure prompt_subst is unset to prevent parameter expansion in preprompt
setopt local_options no_prompt_subst
# check that no command is currently running, the preprompt will otherwise be rendered in the wrong place
@@ -192,6 +195,11 @@ prompt_pure_preprompt_render() {
# modify previous preprompt
print -Pn "${clr_prev_preprompt}\e[${lines}A\e[${COLUMNS}D${preprompt}${clr}\n"
if [[ $prompt_subst_status = 'on' ]]; then
# re-eanble prompt_subst for expansion on PS1
setopt prompt_subst
fi
# redraw prompt (also resets cursor position)
zle && zle .reset-prompt
fi
@@ -324,6 +332,8 @@ prompt_pure_setup() {
zmodload zsh/datetime
zmodload zsh/zle
zmodload zsh/parameter
autoload -Uz add-zsh-hook
autoload -Uz vcs_info
autoload -Uz async && async