Allow overriding of prompt addition (#24)

Some environments have stringent security features that do not allow the
execution of functions inside `$PROMPT_COMMAND`, breaking every individual
theme.

We now allow the overriding of the prompt setter command to workaround
this.
This commit is contained in:
Erwin Jansen
2018-08-13 08:18:49 +02:00
committed by Toan Nguyen
parent ee619e26ed
commit 246d698e4c

View File

@ -499,6 +499,12 @@ function aws_profile {
fi
}
# Returns true if $1 is a shell function.
fn_exists() {
type $1 | grep -q 'shell function'
}
function safe_append_prompt_command {
local prompt_re
@ -511,6 +517,12 @@ function safe_append_prompt_command {
prompt_re="\<${1}\>"
fi
# See if we need to use the overriden version
if [[ $(fn_exists append_prompt_command_override) ]]; then
append_prompt_command_override $1
return
fi
if [[ ${PROMPT_COMMAND} =~ ${prompt_re} ]]; then
return
elif [[ -z ${PROMPT_COMMAND} ]]; then