summaryrefslogtreecommitdiff
path: root/plugins/timer
diff options
context:
space:
mode:
authorNathaniel.Belles <36868971+Nbelles@users.noreply.github.com>2024-06-12 13:07:01 -0400
committerGitHub <noreply@github.com>2024-06-12 19:07:01 +0200
commit6c021fd432aae13ef594342f9b3739ccaca4fcdc (patch)
tree8a6115935b18f02a5931b2105ae75035dc489b0a /plugins/timer
parent11e84bf4f783100c162f2273d72fccc22eb2756d (diff)
downloadzsh-6c021fd432aae13ef594342f9b3739ccaca4fcdc.tar.gz
zsh-6c021fd432aae13ef594342f9b3739ccaca4fcdc.tar.bz2
zsh-6c021fd432aae13ef594342f9b3739ccaca4fcdc.zip
fix(timer): skip timer after running `clear` (#12370)
Co-authored-by: Marc Cornellà <marc@mcornella.com>
Diffstat (limited to 'plugins/timer')
-rw-r--r--plugins/timer/timer.plugin.zsh3
1 files changed, 3 insertions, 0 deletions
diff --git a/plugins/timer/timer.plugin.zsh b/plugins/timer/timer.plugin.zsh
index b261f71c5..d21d59989 100644
--- a/plugins/timer/timer.plugin.zsh
+++ b/plugins/timer/timer.plugin.zsh
@@ -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
}