Add LP_DEBUG_TIME for bash: if 1 shows PS1 build time

Doesn't work on zsh: looks like 'time' doesn't output anything if
applied to a shell function. Need a zsh expert.
This commit is contained in:
Olivier Mengué 2013-06-12 15:11:13 +02:00
parent cf2ff289c8
commit f610ed4f2b

View File

@ -295,6 +295,8 @@ _lp_source_config()
LP_COLORMAP_8=${LP_COLORMAP_8:-$CRIT_RED}
LP_COLORMAP_9=${LP_COLORMAP_9:-$DANGER_RED}
# Debugging flags
LP_DEBUG_TIME=${LP_DEBUG_TIME:-0}
# Default config file may be the XDG standard ~/.config/liquidpromptrc,
# but heirloom dotfile has priority.
@ -1570,10 +1572,19 @@ prompt_on()
fi
if $_LP_SHELL_bash; then
PROMPT_COMMAND=_lp_set_prompt
[[ "$LP_DEBUG_TIME" == 1 ]] && PROMPT_COMMAND="time $PROMPT_COMMAND"
else # zsh
function precmd {
_lp_set_prompt
}
# That doesn't seem to work: no time output
#if [[ "$LP_DEBUG_TIME" == 1 ]]; then
# function precmd {
# local TIMEFMT='LiquidPrompt build time: %*E'
# time _lp_set_prompt
# }
#else
function precmd {
_lp_set_prompt
}
#fi
fi
# Keep in mind that LP has been sourced