From 246d698e4c8cfc74e0e99453ce6ebf944e7d31ed Mon Sep 17 00:00:00 2001 From: Erwin Jansen Date: Mon, 13 Aug 2018 08:18:49 +0200 Subject: [PATCH] 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. --- themes/base.theme.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/themes/base.theme.sh b/themes/base.theme.sh index bc53666..430382e 100644 --- a/themes/base.theme.sh +++ b/themes/base.theme.sh @@ -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