fix #5816: init bash: add case for vscode integrated terminal

This commit is contained in:
NeodymiumFerBore 2024-03-03 00:49:57 +01:00
parent f66bfd9435
commit a034121bb3

View File

@ -125,6 +125,12 @@ else
# add multiple instances of the starship function and keep other user functions if any. # add multiple instances of the starship function and keep other user functions if any.
if [[ -z "${PROMPT_COMMAND-}" ]]; then if [[ -z "${PROMPT_COMMAND-}" ]]; then
PROMPT_COMMAND="starship_precmd" PROMPT_COMMAND="starship_precmd"
# If we are running in vscode with shell integration
elif [[ "$PROMPT_COMMAND" == "__vsc_prompt_cmd_original" ]]; then
# if starship_precmd is not in vscode prompt command list, add it
if [[ ! ${__vsc_original_prompt_command[@]} =~ $(printf "\<starship_precmd\>") ]]; then
__vsc_original_prompt_command+=("starship_precmd")
fi
elif [[ "$PROMPT_COMMAND" != *"starship_precmd"* ]]; then elif [[ "$PROMPT_COMMAND" != *"starship_precmd"* ]]; then
# Appending to PROMPT_COMMAND breaks exit status ($?) checking. # Appending to PROMPT_COMMAND breaks exit status ($?) checking.
# Prepending to PROMPT_COMMAND breaks "command duration" module. # Prepending to PROMPT_COMMAND breaks "command duration" module.