mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-28 18:53:29 +01:00
timer: threshold to show timers only for time-consuming commands (#8151)
This commit is contained in:
parent
68b98c9d53
commit
ff7618cf74
@ -3,6 +3,7 @@ This plugin allows to display command's execution time in a very nonintrusive wa
|
||||
Timer can be tuned by these two variables:
|
||||
* `TIMER_PRECISION` allows to control number of decimal places (default `1`)
|
||||
* `TIMER_FORMAT` allows to adjust display format (default `'/%d'`)
|
||||
* `TIMER_THRESHOLD` allows to set the minimum execution time that causes the timer to be shown (default `0`)
|
||||
|
||||
Sample session:
|
||||
|
||||
|
@ -19,10 +19,12 @@ __timer_display_timer_precmd() {
|
||||
local cmd_end_time=$(__timer_current_time)
|
||||
local tdiff=$((cmd_end_time - __timer_cmd_start_time))
|
||||
unset __timer_cmd_start_time
|
||||
if [[ -z "${TIMER_THRESHOLD}" || ${tdiff} -ge "${TIMER_THRESHOLD}" ]]; then
|
||||
local tdiffstr=$(__timer_format_duration ${tdiff})
|
||||
local cols=$((COLUMNS - ${#tdiffstr} - 1))
|
||||
echo -e "\033[1A\033[${cols}C ${tdiffstr}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
autoload -U add-zsh-hook
|
||||
|
Loading…
Reference in New Issue
Block a user