diff options
author | Munif Tanjim <muniftanjim@gmail.com> | 2020-06-10 22:53:56 +0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-10 18:53:56 +0200 |
commit | 525dfef9a797841287ceef4a95001aec85fc240f (patch) | |
tree | 5c69b90dfc6301b6dcd9bc0a8941d53a6c734e6d /src/init | |
parent | 27ba0accafb65206ddf5b73da87e1d6ed83d980d (diff) |
fix(bash): last command status and command duration (#1185)
* fix: character module last command status for bash
* fix: command duration module for bash
Diffstat (limited to 'src/init')
-rw-r--r-- | src/init/starship.bash | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/init/starship.bash b/src/init/starship.bash index 426063dea..663647e2e 100644 --- a/src/init/starship.bash +++ b/src/init/starship.bash @@ -34,6 +34,8 @@ starship_precmd() { # Run the bash precmd function, if it's set. If not set, evaluates to no-op "${starship_precmd_user_func-:}" + eval "$_PRESERVED_PROMPT_COMMAND" + # Prepare the timer data, if needed. if [[ $STARSHIP_START_TIME ]]; then STARSHIP_END_TIME=$(::STARSHIP:: time) @@ -70,8 +72,12 @@ else if [[ -z "$PROMPT_COMMAND" ]]; then PROMPT_COMMAND="starship_precmd" elif [[ "$PROMPT_COMMAND" != *"starship_precmd" ]]; then - # Remove any trailing semicolon before appending (PR #784) - PROMPT_COMMAND="${PROMPT_COMMAND%;};starship_precmd;" + # Appending to PROMPT_COMMAND breaks exit status ($?) checking. + # Prepending to PROMPT_COMMAND breaks "command duration" module. + # So, we are preserving the existing PROMPT_COMMAND + # which will be executed later in the starship_precmd function + _PRESERVED_PROMPT_COMMAND="$PROMPT_COMMAND" + PROMPT_COMMAND="starship_precmd" fi fi |