6c021fd432aae13ef594342f9b3739ccaca4fcdc

Author
Nathaniel.Belles <36868971+Nbelles@users.noreply.github.com>
Committer
GitHub <noreply@github.com>
Date

Message

fix(timer): skip timer after running `clear` (#12370)

Co-authored-by: Marc Cornellà <marc@mcornella.com>

Diff

 1diff --git a/plugins/timer/timer.plugin.zsh b/plugins/timer/timer.plugin.zsh
 2index b261f71c58ddfdd9eb80de14546d63f783d8b91a..d21d59989cf1ee79d27508e7c1579eed968cd410 100644
 3--- a/plugins/timer/timer.plugin.zsh
 4+++ b/plugins/timer/timer.plugin.zsh
 5@@ -23,9 +23,12 @@ __timer_display_timer_precmd() {
 6     local tdiff=$((cmd_end_time - __timer_cmd_start_time))
 7     unset __timer_cmd_start_time
 8     if [[ -z "${TIMER_THRESHOLD}" || ${tdiff} -ge "${TIMER_THRESHOLD}" ]]; then
 9+      local last_cmd="${history[$((HISTCMD - 1))]%% *}"
10+      if [[ "$last_cmd" != clear ]]; then
11         local tdiffstr=$(__timer_format_duration ${tdiff})
12         local cols=$((COLUMNS - ${#tdiffstr} - 1))
13         echo -e "\033[1A\033[${cols}C ${tdiffstr}"
14+      fi 
15     fi
16   fi
17 }