mirror of
https://github.com/ohmybash/oh-my-bash.git
synced 2024-05-11 05:55:37 +00:00
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:
committed by
Toan Nguyen
parent
ee619e26ed
commit
246d698e4c
@ -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
|
||||
|
Reference in New Issue
Block a user