support bash-preexec

pull/1085/head
Wei-Han Chen 2017-11-07 02:51:27 +08:00
parent 5df98aeac9
commit 5ff7df1607
1 changed files with 30 additions and 13 deletions

View File

@ -499,9 +499,25 @@ function aws_profile {
fi
}
function __check_precmd_conflict() {
local f
for f in "${precmd_functions[@]}"; do
if [[ "${f}" == "${1}" ]]; then
return 0
fi
done
return 1
}
function safe_append_prompt_command {
local prompt_re
if [ "${__bp_imported}" == "defined" ]; then
# We are using bash-preexec
if ! __check_precmd_conflict "${1}" ; then
precmd_functions+=("${1}")
fi
else
# Set OS dependent exact match regular expression
if [[ ${OSTYPE} == darwin* ]]; then
# macOS
@ -518,4 +534,5 @@ function safe_append_prompt_command {
else
PROMPT_COMMAND="${1};${PROMPT_COMMAND}"
fi
fi
}