bug: Use en_US when fetching EPOCHREALTIME

Isolates fetching of EPOCHREALTIME to a function which sets LC_ALL=en_US.UTF-8.
This ensures that the value is in decimal format, regardless of runtime locale.

bug: Hide duration when no command executed
This commit is contained in:
David Farrell
2022-10-26 15:23:11 -07:00
parent 1c9cfd056b
commit 7c7e4f90ec
3 changed files with 23 additions and 7 deletions

View File

@@ -4,7 +4,8 @@ about-plugin 'Alert (BEL) when process ends after a threshold of seconds'
function precmd_return_notification() {
local command_start="${COMMAND_DURATION_START_SECONDS:=0}"
local current_time="${EPOCHREALTIME:-$SECONDS}"
local current_time
current_time="$(_shell_duration_en)"
local -i command_duration="$((${current_time%.*} - ${command_start%.*}))"
if [[ "${command_duration}" -gt "${NOTIFY_IF_COMMAND_RETURNS_AFTER:-5}" ]]; then
printf '\a'