Merge pull request #2119 from BarbUk/fix/command_duration_precision
Fix/command duration precisionpull/2138/head
commit
d1b831a92d
|
|
@ -25,9 +25,11 @@ function _command_duration() {
|
||||||
local -i minutes=0 seconds=0 deciseconds=0
|
local -i minutes=0 seconds=0 deciseconds=0
|
||||||
local -i command_start_seconds="${command_start%.*}"
|
local -i command_start_seconds="${command_start%.*}"
|
||||||
local -i command_start_deciseconds=$((10#${command_start##*.}))
|
local -i command_start_deciseconds=$((10#${command_start##*.}))
|
||||||
|
command_start_deciseconds="${command_start_deciseconds:0:1}"
|
||||||
local current_time="${EPOCHREALTIME:-$SECONDS}"
|
local current_time="${EPOCHREALTIME:-$SECONDS}"
|
||||||
local -i current_time_seconds="${current_time%.*}"
|
local -i current_time_seconds="${current_time%.*}"
|
||||||
local -i current_time_deciseconds="$((10#${current_time##*.}))"
|
local -i current_time_deciseconds="$((10#${current_time##*.}))"
|
||||||
|
current_time_deciseconds="${current_time_deciseconds:0:1}"
|
||||||
|
|
||||||
if [[ "${command_start_seconds:-0}" -gt 0 ]]; then
|
if [[ "${command_start_seconds:-0}" -gt 0 ]]; then
|
||||||
# seconds
|
# seconds
|
||||||
|
|
@ -50,9 +52,9 @@ function _command_duration() {
|
||||||
|
|
||||||
_dynamic_clock_icon "${command_duration}"
|
_dynamic_clock_icon "${command_duration}"
|
||||||
if ((minutes > 0)); then
|
if ((minutes > 0)); then
|
||||||
printf "%s%s%dm %ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$minutes" "$seconds"
|
printf "%s %s%dm %ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$minutes" "$seconds"
|
||||||
elif ((seconds >= COMMAND_DURATION_MIN_SECONDS)); then
|
elif ((seconds >= COMMAND_DURATION_MIN_SECONDS)); then
|
||||||
printf "%s%s%d.%01ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$seconds" "$deciseconds"
|
printf "%s %s%d.%01ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$seconds" "$deciseconds"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue