https://github.com/zimfw/duration-info
Exposes to prompts how long the last command took to execute.
https://github.com/zimfw/duration-info
duration zim zimfw zsh zsh-plugin zsh-plugins zsh-prompt zsh-theme
Last synced: 30 days ago
JSON representation
Exposes to prompts how long the last command took to execute.
- Host: GitHub
- URL: https://github.com/zimfw/duration-info
- Owner: zimfw
- License: mit
- Created: 2021-03-26T04:02:20.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-11-01T00:59:20.000Z (over 2 years ago)
- Last Synced: 2025-02-04T21:43:33.023Z (3 months ago)
- Topics: duration, zim, zimfw, zsh, zsh-plugin, zsh-plugins, zsh-prompt, zsh-theme
- Language: Shell
- Homepage:
- Size: 3.91 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
duration-info
=============Exposes to prompts how long the last command took to execute.
Settings
--------By default, the duration information will be only set if the command took at
least 2 seconds to execute. The threshold value, in seconds, can be customized
with:zstyle ':zim:duration-info' threshold
The threshold value can be a decimal number. If the threshold value is less than
1, then milliseconds are automatically shown.Milliseconds can also be directly enabled with the following zstyle:
zstyle ':zim:duration-info' show-milliseconds yes
Theming
-------To configure the format of the duration information, use the following syntax in
your prompt code:zstyle ':zim:duration-info' format ''
The occurrence of the `%d` code in the format string is substituted by the
duration, and the `duration_info` variable is set to the formatted string. If
the duration is less than the threshold, the variable is unset instead.In your prompt code, add `${duration_info}` to where you want the duration
information to be displayed. Usually, you'll add it to the value of either `PS1`
or `RPS1`. Also, add the `duration-info-preexec` and `duration-info-precmd`
functions to the preexec and precmd hooks respectively.Here's an example:
```zsh
setopt nopromptbang prompt{cr,percent,sp,subst}zstyle ':zim:duration-info' threshold 0.5
zstyle ':zim:duration-info' format '(%d) 'autoload -Uz add-zsh-hook
add-zsh-hook preexec duration-info-preexec
add-zsh-hook precmd duration-info-precmdPS1='${duration_info}%# '
```