Fix compatibility with bash-preexec

Created by: ismith

bash-preexec "provides preexec and precmd hook functions for Bash in the style of Zsh".

Unfortunately, it interferes with trap DEBUG and PROMPT_COMMAND behavior used by LP_ENABLE_ERROR and LP_ENABLE_RUNTIME.

Fortunately, since liquidprompt already supports add-zsh-hook behavior, we can use those hooks as guides to where we should add hooks for bash-preexec.

These hooks get set if __bp_imported is "defined"; this is set by bash-preexec.



  • with LP_ENABLE_ERROR=1, running false should put a 1 at the end of the prompt
  • with LP_ENABLE_RUNTIME=1 and LP_RUNTIME_THRESHOLD=2, sleep 3 should put a 3 at the end of the prompt
  • Optionally, you can run both of the above at once: sleep 3 && false
  • prompt_off and prompt_on still work


  • with bash-preexec installed, and enabled in ~/.bashrc: source ~/
  • with bash-preexec installed, but the source line commented out (checking that this PR does not break existing behavior)

Merge request reports