diff options
author | Dominik Ritter <dritter03@googlemail.com> | 2017-02-14 01:11:53 +0300 |
---|---|---|
committer | Dominik Ritter <dritter03@googlemail.com> | 2017-02-14 01:17:04 +0300 |
commit | 04e75a683d442e8662b09202978504a372c0b2a5 (patch) | |
tree | 6d3ca8403393e5f44dd15552887deb7ef67fcd48 /powerlevel9k.zsh-theme | |
parent | 7e5bef14d76029df4474ad8cc5e3d9582fdffcd8 (diff) |
Reworked `command_execution_time` segment
- Add a visual identifier
- Fix a bug that the time was not reset
- Make calculation independent of segment (thx @rjorgenson)
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-x | powerlevel9k.zsh-theme | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index de00496c..840dde14 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -564,9 +564,8 @@ prompt_custom() { prompt_command_execution_time() { set_default POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD 3 - local timing=$((EPOCHSECONDS - _P9K_TIMER_START)) - if [ $timing -ge $POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD ]; then - "$1_prompt_segment" "$0" "$2" "red" "226" "Dur ${timing}" '' + if [ $_P9K_COMMAND_DURATION -ge $POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD ]; then + "$1_prompt_segment" "$0" "$2" "red" "226" "${_P9K_COMMAND_DURATION}s" 'EXECUTION_TIME_ICON' fi } @@ -1181,6 +1180,10 @@ powerlevel9k_preexec() { powerlevel9k_prepare_prompts() { RETVAL=$? + _P9K_COMMAND_DURATION=$((EPOCHSECONDS - _P9K_TIMER_START)) + # Reset start time + _P9K_TIMER_START=99999999999 + if [[ "$POWERLEVEL9K_PROMPT_ON_NEWLINE" == true ]]; then PROMPT="$(print_icon 'MULTILINE_FIRST_PROMPT_PREFIX')%f%b%k$(build_left_prompt) $(print_icon 'MULTILINE_SECOND_PROMPT_PREFIX')" |