bash: save and set shell option promptvars

This commit is contained in:
Olivier Mengué 2014-06-30 19:42:51 +02:00
parent 943144cd12
commit 62f0270888

View File

@ -1721,11 +1721,13 @@ prompt_on()
LP_OLD_PS1="$PS1"
if $_LP_SHELL_bash; then
LP_OLD_PROMPT_COMMAND="$PROMPT_COMMAND"
LP_OLD_SHOPT="$(shopt -p promptvars)"
else # zsh
LP_OLD_PROMPT_COMMAND="$(whence -f precmd)"
fi
fi
if $_LP_SHELL_bash; then
shopt -s promptvars
PROMPT_COMMAND=_lp_set_prompt
[[ "$LP_DEBUG_TIME" == 1 ]] && PROMPT_COMMAND="time $PROMPT_COMMAND"
else # zsh
@ -1752,6 +1754,7 @@ prompt_off()
{
PS1=$LP_OLD_PS1
if $_LP_SHELL_bash; then
eval "$LP_OLD_SHOPT"
PROMPT_COMMAND="$LP_OLD_PROMPT_COMMAND"
else # zsh
precmd() { : ; }
@ -1764,6 +1767,7 @@ prompt_OFF()
{
PS1="\$ "
if $_LP_SHELL_bash; then
shopt -u promptvars
PROMPT_COMMAND="$LP_OLD_PROMPT_COMMAND"
else # zsh
precmd() { : ; }