diff options
author | Frederick Zhang <frederick888@tsundere.moe> | 2020-07-15 02:53:37 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-14 18:53:37 +0200 |
commit | ff7618cf744a289a9ba9c332be08ed5304d2f45f (patch) | |
tree | 53516343d538cf5d7a4f7f404db7fde133a70fe1 /plugins/timer/timer.plugin.zsh | |
parent | 68b98c9d53a4dd0c53d25a9595305e2318af0e2b (diff) | |
download | zsh-ff7618cf744a289a9ba9c332be08ed5304d2f45f.tar.gz zsh-ff7618cf744a289a9ba9c332be08ed5304d2f45f.tar.bz2 zsh-ff7618cf744a289a9ba9c332be08ed5304d2f45f.zip |
timer: threshold to show timers only for time-consuming commands (#8151)
Diffstat (limited to 'plugins/timer/timer.plugin.zsh')
-rw-r--r-- | plugins/timer/timer.plugin.zsh | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/plugins/timer/timer.plugin.zsh b/plugins/timer/timer.plugin.zsh index 728377c5c..1be7516a3 100644 --- a/plugins/timer/timer.plugin.zsh +++ b/plugins/timer/timer.plugin.zsh @@ -19,9 +19,11 @@ __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 - local tdiffstr=$(__timer_format_duration ${tdiff}) - local cols=$((COLUMNS - ${#tdiffstr} - 1)) - echo -e "\033[1A\033[${cols}C ${tdiffstr}" + 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 } |