zsh-command-time
Plugin that output time: xx
after long commands and export ZSH_COMMAND_TIME
variable for usage in your scripts.
It similar builin feature REPORTTIME, but it outputs only
if user + system time >= REPORTTIME
in config. For example:
$ time sleep 3
sleep 3 0,00s user 0,00s system 0% cpu 3,008 total
Sleep don't consume any cpu time and REPORTTIME
"don't see" such idle commands.
If you need to monitor only cpu-angry commands, use REPORTTIME
instead this plugin.
Install with antigen
antigen bundle popstas/zsh-command-time
Install for oh-my-zsh
Download:
git clone https://github.com/popstas/zsh-command-time.git ~/.oh-my-zsh/custom/plugins/command-time
And add command-time
to plugins
in .zshrc
.
Configuration
You can override defaults in .zshrc
:
# If command execution time above min. time, plugins will not output time.
ZSH_COMMAND_TIME_MIN_SECONDS=3
# Message to display (set to "" for disable).
ZSH_COMMAND_TIME_MSG="Execution time: %s sec"
powerlevel9k theme
Usage withYou should not want to use this plugin with powerlevel9k. Sinse powerlevel9k v0.6.0 theme have native segment command_execution_time (see PR), so you can just add it to your prompt:
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status background_jobs vcs command_execution_time time)
If you still want to use it with powerlevel9k, add custom element in .zshrc
:
POWERLEVEL9K_CUSTOM_COMMAND_TIME="zsh_command_time"
POWERLEVEL9K_CUSTOM_COMMAND_TIME_BACKGROUND="253" # white
POWERLEVEL9K_CUSTOM_COMMAND_TIME_FOREGROUND="000" # black
And add element custom_command_time
to your prompt:
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status background_jobs vcs custom_command_time time)
Provision with ansible
Plugin Plugin excluded from viasite-ansible.zsh, but you can still check role.command-time
included in ansible role viasite-ansible/ansible-role-zsh
with other useful plugins.