Skip to content

Commit

Permalink
feat(zsh): crispy theme support smart time other than ms only
Browse files Browse the repository at this point in the history
  • Loading branch information
crispgm committed Feb 22, 2021
1 parent 279ed2c commit 9c0c368
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions zsh/crispy.zsh-theme
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,26 @@ function precmd() {
if [ $timer ]; then
now=$(($(print -P %D{%s%6.})/1000))
elapsed=$(($now-$timer))

unit="ms"
if [[ $elapsed -ge 1000 ]]; then
elapsed=$(($elapsed/1000))
unit="s"
if [[ $elapsed -ge 60 ]]; then
elapsed=$(($elapsed/60))
unit="m"
if [[ $elapsed -ge 60 ]]; then
elapsed=$(($elapsed/60))
unit="h"
fi
fi
fi
elapsed="$elapsed$unit"
unset timer
fi
}

function prompt_elapse {
echo "%{$fg[cyan]%}${elapsed}ms %{$reset_color%}"
echo "%{$fg[cyan]%}${elapsed} %{$reset_color%}"
}

function prompt_char {
Expand Down

0 comments on commit 9c0c368

Please sign in to comment.