aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2019-07-20 13:41:52 +0300
committerromkatv <roman.perepelitsa@gmail.com>2019-07-20 13:41:52 +0300
commitc4d3ec2cc5b146a277118ab5abddf8d904bad011 (patch)
tree526fd5bbffb5db31534c5a6ac678764b8b98343c /internal
parent2683653ed2269f53ab0f164637cf91ba7643a331 (diff)
add POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT
Diffstat (limited to 'internal')
-rwxr-xr-xinternal/p10k.zsh34
1 files changed, 22 insertions, 12 deletions
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