From 9907244548ee0a2a5890206cdf060bf1e7b5c065 Mon Sep 17 00:00:00 2001 From: Chapman Pendery <35637443+cpendery@users.noreply.github.com> Date: Sat, 9 Mar 2024 14:58:12 -0800 Subject: [PATCH] fix: shell integration with oh-my-bash (#200) Signed-off-by: Chapman Pendery --- shell/shellIntegration.bash | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/shell/shellIntegration.bash b/shell/shellIntegration.bash index 90c0704..f86a97c 100644 --- a/shell/shellIntegration.bash +++ b/shell/shellIntegration.bash @@ -51,9 +51,14 @@ __is_update_cwd() { } if [[ -n "${bash_preexec_imported:-}" ]]; then - precmd_functions+=(__is_update_cwd) + precmd_functions+=(__is_precmd) fi +__is_precmd() { + __is_update_cwd + __is_update_prompt +} + __is_update_prompt() { if [[ "$__is_custom_PS1" == "" || "$__is_custom_PS1" != "$PS1" ]]; then __is_original_PS1=$PS1 @@ -65,4 +70,19 @@ __is_update_prompt() { fi } -__is_update_prompt \ No newline at end of file +__is_prompt_cmd_original() { + for cmd in "${__is_original_prompt_command[@]}"; do + eval "${cmd:-}" + done + __is_precmd +} + + +__is_original_prompt_command=${PROMPT_COMMAND:-} +if [[ -z "${bash_preexec_imported:-}" ]]; then + if [[ -n "${__is_original_prompt_command:-}" && "${__is_original_prompt_command:-}" != "__is_precmd" ]]; then + PROMPT_COMMAND=__is_prompt_cmd_original + else + PROMPT_COMMAND=__is_precmd + fi +fi \ No newline at end of file