fix(bash): improve integration with bash-preexec (#5734)

This commit is contained in:
David Knaack 2024-02-04 16:02:17 +01:00 committed by GitHub
parent 428d840bce
commit 2aa711ccc7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -36,7 +36,7 @@ starship_precmd() {
if [[ ${BLE_ATTACHED-} && ${#BLE_PIPESTATUS[@]} -gt 0 ]]; then if [[ ${BLE_ATTACHED-} && ${#BLE_PIPESTATUS[@]} -gt 0 ]]; then
STARSHIP_PIPE_STATUS=("${BLE_PIPESTATUS[@]}") STARSHIP_PIPE_STATUS=("${BLE_PIPESTATUS[@]}")
fi fi
if [[ -n "${BP_PIPESTATUS-}" ]] && [[ "${#BP_PIPESTATUS[@]}" -gt "${#STARSHIP_PIPE_STATUS[@]}" ]]; then if [[ -n "${BP_PIPESTATUS-}" ]] && [[ "${#BP_PIPESTATUS[@]}" -gt 0 ]]; then
STARSHIP_PIPE_STATUS=(${BP_PIPESTATUS[@]}) STARSHIP_PIPE_STATUS=(${BP_PIPESTATUS[@]})
fi fi
@ -92,7 +92,7 @@ if [[ ${BLE_VERSION-} && _ble_version -ge 400 ]]; then
blehook PRECMD!='starship_precmd' blehook PRECMD!='starship_precmd'
# If the user appears to be using https://github.com/rcaloras/bash-preexec, # If the user appears to be using https://github.com/rcaloras/bash-preexec,
# then hook our functions into their framework. # then hook our functions into their framework.
elif [[ "${__bp_imported:-}" == "defined" || -n "${preexec_functions-}" || -n "${precmd_functions-}" ]]; then elif [[ -n "${bash_preexec_imported:-}" || -n "${__bp_imported:-}" || -n "${preexec_functions-}" || -n "${precmd_functions-}" ]]; then
# bash-preexec needs a single function--wrap the args into a closure and pass # bash-preexec needs a single function--wrap the args into a closure and pass
starship_preexec_all(){ starship_preexec "$_"; } starship_preexec_all(){ starship_preexec "$_"; }
preexec_functions+=(starship_preexec_all) preexec_functions+=(starship_preexec_all)