Skip to content

Commit

Permalink
zsh: save and restore a prompt set with zsh' promptinit
Browse files Browse the repository at this point in the history
Zsh has a framework for Prompt plugins.
(see /usr/share/zsh/functions/Prompts/promptinit)

If a prompt has been enabled when LiquidPrompt is loaded, we save the
prompt and restore it when prompt_off is called by the user.
  • Loading branch information
dolmen committed Jan 14, 2016
1 parent 454112f commit 02bc49e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions liquidprompt
Original file line number Diff line number Diff line change
Expand Up @@ -1833,6 +1833,12 @@ prompt_on()
LP_OLD_SHOPT="$(shopt -p promptvars)"
else # zsh
LP_OLD_PROMPT_COMMAND="$(whence -f precmd)"
_LP_ZSH_PROMPT_THEME=""
if [[ -n "$prompt_theme" && "$prompt_theme" != off ]]; then
_LP_ZSH_PROMPT_THEME="$prompt_theme"
# Disable the prompt to disable its precmd hook
prompt off
fi
_LP_OLD_SETOPT=()
# Dump option names: echo ${(ko)options}
for o in promptpercent promptbang promptsubst
Expand Down Expand Up @@ -1877,6 +1883,7 @@ prompt_off()
else # zsh
add-zsh-hook -d precmd $_LP_ZSH_HOOK
setopt ${_LP_OLD_SETOPT}
(( ${#_LP_ZSH_PROMPT_THEME} )) && prompt $_LP_ZSH_PROMPT_THEME
eval "$LP_OLD_PROMPT_COMMAND"
fi
}
Expand Down

0 comments on commit 02bc49e

Please sign in to comment.