From 8bc9add56b55d524a1f22009de5c9a92db032f9d Mon Sep 17 00:00:00 2001 From: "U-SYNOPSYS\\jstolp" Date: Mon, 19 Aug 2019 19:00:06 +0200 Subject: zshrc: added cmd time hooks --- zshrc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'zshrc') diff --git a/zshrc b/zshrc index d128190..42766c7 100644 --- a/zshrc +++ b/zshrc @@ -173,6 +173,7 @@ color[brightRed]='%F{196}' color[pinkRed]='%F{125}' color[babyBlue]='%F{38}' color[darkBlue]='%F{26}' +color[green]='%F{2}' function printBase16() { for i in $(seq 0 15); do @@ -233,6 +234,26 @@ function _uninstallMyPrompt() { #_installMyPrompt _installMyPromptBase16 +# hooks see man zshmisc(1) + +function preexec_cmdTime() { + timer=$SECONDS +} + +function precmd_cmdTime() { + [[ ! -z $timer ]] && print -P "\-> $color[green]$(($SECONDS - $timer))$color[noColor]s" +} + +function enableCmdTime() { + preexec_functions+=(preexec_cmdTime) + precmd_functions+=(precmd_cmdTime) +} + +function disableCmdTime() { + preexec_functions=(${preexec_functions#preexec_cmdTime}) + precmd_functions=(${precmd_functions#precmd_cmdTime}) +} + # need to do after compinit zshPlug 'zsh-users/zsh-syntax-highlighting' -- cgit v1.2.3