Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions bash_command_timer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ fi
# flag is set and clear it after the first execution.
BCT_AT_PROMPT=1
function BCTPreCommand() {
local EXIT="$?"
if [ $EXIT == 0 ]
then
BCT_COLOR='38;5;028'
else
BCT_COLOR='38;5;052'
fi
if [ -z "$BCT_AT_PROMPT" ]; then
return
fi
Expand Down Expand Up @@ -161,9 +168,10 @@ function BCTPostCommand() {
local num_msecs_pretty=$(printf '%03d' $num_msecs)
fi
time_str="${time_str}${num_secs}s${num_msecs_pretty}"
start_str=$(BCTPrintTime $(($command_start_time / $SEC)))
now_str=$(BCTPrintTime $(($command_end_time / $SEC)))
if [ -n "$now_str" ]; then
local output_str="[ $time_str | $now_str ]"
if [ -n "$now_str" ] && [ -n "$start_str" ]; then
local output_str="[ $time_str | $start_str > $now_str ]"
else
local output_str="[ $time_str ]"
fi
Expand Down