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

Co-authored-by: Marc Cornellà <marc@mcornella.com>
This commit is contained in:
Nathaniel.Belles 2024-06-12 13:07:01 -04:00 committed by GitHub
parent 11e84bf4f7
commit 6c021fd432
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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
}