summaryrefslogtreecommitdiff
path: root/plugins/timer/timer.plugin.zsh
diff options
context:
space:
mode:
authorTuowen Zhao <ztuowen@gmail.com>2026-01-04 22:47:54 -0800
committerTuowen Zhao <ztuowen@gmail.com>2026-01-04 22:47:54 -0800
commit2aa4cb7a52b28722816ecfd55f3b06293332c55c (patch)
treef02a9f3d59d109c70caf932a24e43368994e0e8c /plugins/timer/timer.plugin.zsh
parent7e951c254e779ff0620537cf43ca69dd878387b4 (diff)
parentd23d3ea69fdb839088e6e5589557cce77b34aaf8 (diff)
downloadzsh-2aa4cb7a52b28722816ecfd55f3b06293332c55c.tar.gz
zsh-2aa4cb7a52b28722816ecfd55f3b06293332c55c.tar.bz2
zsh-2aa4cb7a52b28722816ecfd55f3b06293332c55c.zip
Merge remote-tracking branch 'github/master'HEADmaster
Diffstat (limited to 'plugins/timer/timer.plugin.zsh')
-rw-r--r--plugins/timer/timer.plugin.zsh5
1 files changed, 4 insertions, 1 deletions
diff --git a/plugins/timer/timer.plugin.zsh b/plugins/timer/timer.plugin.zsh
index b261f71c5..6baf1f681 100644
--- a/plugins/timer/timer.plugin.zsh
+++ b/plugins/timer/timer.plugin.zsh
@@ -6,7 +6,7 @@ __timer_current_time() {
}
__timer_format_duration() {
- local mins=$(printf '%.0f' $(($1 / 60)))
+ local mins=$(printf '%.0f' $(($(IFS='.' read int dec <<< "$1"; echo $int) / 60)))
local secs=$(printf "%.${TIMER_PRECISION:-1}f" $(($1 - 60 * mins)))
local duration_str=$(echo "${mins}m${secs}s")
local format="${TIMER_FORMAT:-/%d}"
@@ -23,9 +23,12 @@ __timer_display_timer_precmd() {
local tdiff=$((cmd_end_time - __timer_cmd_start_time))
unset __timer_cmd_start_time
if [[ -z "${TIMER_THRESHOLD}" || ${tdiff} -ge "${TIMER_THRESHOLD}" ]]; then
+ local last_cmd="${history[$((HISTCMD - 1))]%% *}"
+ if [[ "$last_cmd" != clear ]]; then
local tdiffstr=$(__timer_format_duration ${tdiff})
local cols=$((COLUMNS - ${#tdiffstr} - 1))
echo -e "\033[1A\033[${cols}C ${tdiffstr}"
+ fi
fi
fi
}