Skip to content

Commit d1b831a

Browse files
authored
Merge pull request #2119 from BarbUk/fix/command_duration_precision
Fix/command duration precision
2 parents 6940701 + 634c1f8 commit d1b831a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/command_duration.bash

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ function _command_duration() {
2525
local -i minutes=0 seconds=0 deciseconds=0
2626
local -i command_start_seconds="${command_start%.*}"
2727
local -i command_start_deciseconds=$((10#${command_start##*.}))
28+
command_start_deciseconds="${command_start_deciseconds:0:1}"
2829
local current_time="${EPOCHREALTIME:-$SECONDS}"
2930
local -i current_time_seconds="${current_time%.*}"
3031
local -i current_time_deciseconds="$((10#${current_time##*.}))"
32+
current_time_deciseconds="${current_time_deciseconds:0:1}"
3133

3234
if [[ "${command_start_seconds:-0}" -gt 0 ]]; then
3335
# seconds
@@ -50,9 +52,9 @@ function _command_duration() {
5052

5153
_dynamic_clock_icon "${command_duration}"
5254
if ((minutes > 0)); then
53-
printf "%s%s%dm %ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$minutes" "$seconds"
55+
printf "%s %s%dm %ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$minutes" "$seconds"
5456
elif ((seconds >= COMMAND_DURATION_MIN_SECONDS)); then
55-
printf "%s%s%d.%01ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$seconds" "$deciseconds"
57+
printf "%s %s%d.%01ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$seconds" "$deciseconds"
5658
fi
5759
}
5860

0 commit comments

Comments
 (0)