Refactor shell integration enabling code

* integration/bash (__eat_enable_integration): New function.
* integration/bash: Move enabling code to dedicated function.
This commit is contained in:
Akib Azmain Turja 2022-12-04 15:20:12 +06:00
parent 0887bd6a7d
commit 01f5f3b2af
No known key found for this signature in database
GPG key ID: 5535FCF54D88616B

View file

@ -50,10 +50,9 @@ __eat_before_exec () {
fi fi
} }
# Add '__eat_prompt_command' as the last element of 'PROMPT_COMMAND'. __eat_enable_integration ()
if test -z "$__eat_bash_integration_enabled" {
then __eat_integration_enabled=yes
__eat_bash_integration_enabled=yes
PS1='\[\e]2;\u@\h:\w$\e\\\]'"$PS1" PS1='\[\e]2;\u@\h:\w$\e\\\]'"$PS1"
PROMPT_COMMAND+=(__eat_prompt_command) PROMPT_COMMAND+=(__eat_prompt_command)
trap '__eat_before_exec' DEBUG trap '__eat_before_exec' DEBUG
@ -73,7 +72,10 @@ then
done done
# Step 2.2: Assign the first element. # Step 2.2: Assign the first element.
PROMPT_COMMAND[0]=__eat_before_prompt_command PROMPT_COMMAND[0]=__eat_before_prompt_command
fi }
# Enable.
test -z "$__eat_integration_enabled" && __eat_enable_integration
# Local Variables: # Local Variables:
# mode: sh # mode: sh