Skip to content

Commit

Permalink
fix(bash): last command status and command duration (starship#1185)
Browse files Browse the repository at this point in the history
* fix: character module last command status for bash

* fix: command duration module for bash
  • Loading branch information
MunifTanjim authored Jun 10, 2020
1 parent 27ba0ac commit 525dfef
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/init/starship.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 525dfef

Please sign in to comment.