jichu4n/bash-command-timer

Change colour of output based on exit status

jwscook opened this issue · 1 comments

It's possible to change the colour of the output based on the exit status of the timed command. Just need to alter BCTPreCommand like so:

function BCTPreCommand() {
  local EXIT="$?"
  if [ $EXIT == 0 ]
  then
    # colour for exit without error
    BCT_COLOR='36'
  else
    # colour for exit with error
    BCT_COLOR='91'
  fi
  if [ -z "$BCT_AT_PROMPT" ]; then
    return
  fi
  unset BCT_AT_PROMPT
  BCT_COMMAND_START_TIME=$(eval $BCTTime)
}

This change is implemented in #10, which is awaiting review.