From f2b4facac89d9da0edce1e3546e3986a03032994 Mon Sep 17 00:00:00 2001 From: BarbUk Date: Sat, 14 Nov 2020 12:42:24 +0400 Subject: [PATCH] Make minimum display time configurable with COMMAND_DURATION_MIN_SECONDS --- plugins/available/cmd-duration.plugin.bash | 7 ++++--- themes/barbuk/barbuk.theme.bash | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/available/cmd-duration.plugin.bash b/plugins/available/cmd-duration.plugin.bash index c6ce7a52..58f290c6 100644 --- a/plugins/available/cmd-duration.plugin.bash +++ b/plugins/available/cmd-duration.plugin.bash @@ -6,6 +6,7 @@ COMMAND_DURATION_TMPDIR="${TMPDIR:-/tmp}" COMMAND_DURATION_FILE="$COMMAND_DURATION_TMPDIR/bashit_theme_execution_$BASHPID" COMMAND_DURATION_ICON='  ' +COMMAND_DURATION_MIN_SECONDS='0' trap _command_duration_delete_temp_file EXIT HUP INT TERM @@ -47,14 +48,14 @@ _command_duration() { command_duration=0 fi - if [[ "$command_duration" -gt 0 ]]; then + if (( command_duration > 0 )); then minutes=$(( command_duration / 60 )) seconds=$(( command_duration % 60 )) fi - if [[ "$minutes" -gt 0 ]]; then + if (( minutes > 0 )); then printf "%s%s%s%dm%d.%01ds" "${COMMAND_DURATION_COLOR}" "$COMMAND_DURATION_ICON" "$normal" "$minutes" "$seconds" "$deciseconds" - elif [[ "$deciseconds" -gt 0 ]]; then + elif (( seconds >= COMMAND_DURATION_MIN_SECONDS )); then printf "%s%s%s%d.%01ds" "${COMMAND_DURATION_COLOR}" "$COMMAND_DURATION_ICON" "$normal" "$seconds" "$deciseconds" fi } diff --git a/themes/barbuk/barbuk.theme.bash b/themes/barbuk/barbuk.theme.bash index 37ce81da..609fd2be 100644 --- a/themes/barbuk/barbuk.theme.bash +++ b/themes/barbuk/barbuk.theme.bash @@ -12,6 +12,7 @@ SCM_SVN_CHAR=${BARBUK_SVN_CHAR:='⑆ '} EXIT_CODE_ICON=${BARBUK_EXIT_CODE_ICON:=' '} PYTHON_VENV_CHAR=${BARBUK_PYTHON_VENV_CHAR:=' '} COMMAND_DURATION_COLOR="$bold_blue" +COMMAND_DURATION_MIN_SECONDS=1 # Ssh user and hostname display SSH_INFO=${BARBUK_SSH_INFO:=true}