summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/p10k-lean.zsh6
-rwxr-xr-xinternal/p10k.zsh34
2 files changed, 24 insertions, 16 deletions
diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh
index 3c388e27..a890ebad 100644
--- a/config/p10k-lean.zsh
+++ b/config/p10k-lean.zsh
@@ -208,10 +208,8 @@ fi
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0
# Execution time color.
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=101
- # Duration format: 1h 2m 3s.
- local d='${${P9K_CONTENT:/(#b)(*):(*):(*)/${match[1]#0}h ${match[2]#0}m ${match[3]#0}s}'
- d+=':/(#b)(*):(*)/${match[1]#0}m ${match[2]#0}s}'
- typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_CONTENT_EXPANSION=$d
+ # Duration format: 1d 2h 3m 4s.
+ typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s'
# Don't show the number of background jobs.
typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=false
diff --git a/internal/p10k.zsh b/internal/p10k.zsh
index 0114d33e..a1116673 100755
--- a/internal/p10k.zsh
+++ b/internal/p10k.zsh
@@ -934,22 +934,21 @@ prompt_custom() {
# Display the duration the command needed to run.
set_default -i POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD 3
set_default -i POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION 2
-set_default POWERLEVEL9K_COMMAND_EXECUTION_TIME_DISABLE_FORMATTING false
+# Other options: "d h m s".
+set_default POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT "H:M:S"
prompt_command_execution_time() {
(( $+P9K_COMMAND_DURATION_SECONDS && P9K_COMMAND_DURATION_SECONDS >= POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD )) || return
- if [[ $POWERLEVEL9K_COMMAND_EXECUTION_TIME_DISABLE_FORMATTING == true ]]; then
- local text=''
- else
- if (( P9K_COMMAND_DURATION_SECONDS < 60 )); then
- if [[ $POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION == 0 ]]; then
- local -i sec=$((P9K_COMMAND_DURATION_SECONDS + 0.5))
- else
- local -F $POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION sec=P9K_COMMAND_DURATION_SECONDS
- fi
- local text=${sec}s
+ if (( P9K_COMMAND_DURATION_SECONDS < 60 )); then
+ if [[ $POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION == 0 ]]; then
+ local -i sec=$((P9K_COMMAND_DURATION_SECONDS + 0.5))
else
- local -i d=$((P9K_COMMAND_DURATION_SECONDS + 0.5))
+ local -F $POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION sec=P9K_COMMAND_DURATION_SECONDS
+ fi
+ local text=${sec}s
+ else
+ local -i d=$((P9K_COMMAND_DURATION_SECONDS + 0.5))
+ if [[ $POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT == "H:M:S" ]]; then
local text=${(l.2..0.)$((d % 60))}
if (( d >= 60 )); then
text=${(l.2..0.)$((d / 60 % 60))}:$text
@@ -959,6 +958,17 @@ prompt_command_execution_time() {
text=0$((d / 3600)):$text
fi
fi
+ else
+ local text="$((d % 60))s"
+ if (( d >= 60 )); then
+ text="$((d / 60 % 60))m $text"
+ if (( d >= 3600 )); then
+ text="$((d / 3600 % 24))h $text"
+ if (( d >= 86400 )); then
+ text="$((d / 86400))d $text"
+ fi
+ fi
+ fi
fi
fi