geometry-zsh / geometry

geometry is a minimal, fully customizable and composable zsh prompt theme
ISC License
921 stars 94 forks source link

exec_time doesn't show in prompt #278

Closed barnsza closed 4 years ago

barnsza commented 4 years ago

I've just started using geometry against the mnml branch and have found that even with geometry_exec_time in a prompt, it doesn't actually show for long running commands.

I don't know much about the internals of ZSH, but I think I've narrowed it down to the fact that the time_command_begin function doesn't fire (the preexec hook doesn't seem to load it). Further testing leads me to believe that this is caused by #273 because if I copy the appropriate few lines from the function file into geometry.zsh, it works.

alxbl commented 4 years ago

It's caused by the autoload -Uk flag which we opted for instead of the changes in #273. Since all ZSH hooks are evaluated in subshells due to the lazy loading, the top-level shell will never initialize the hooks. We're discussing in #272, and I think we're likely to revert the lazy loading for now until we can find a working approach to do it. For now you can change the line autoload -Uk $fun in geometry.zsh back to . $fun for a temporary fix... here's the diff:

diff --git a/geometry.zsh b/geometry.zsh
index dc4942d..f1f066d 100644
--- a/geometry.zsh
+++ b/geometry.zsh
@@ -12,7 +12,7 @@ typeset -gA GEOMETRY; GEOMETRY[ROOT]=${0:A:h}

 autoload -U add-zsh-hook

-function { local fun; for fun ("${GEOMETRY[ROOT]}"/functions/*) autoload -Uk $fun }
+function { local fun; for fun ("${GEOMETRY[ROOT]}"/functions/*) . $fun }

 (( $+functions[ansi] )) || ansi() { (($# - 2)) || echo -n "%F{$1}$2%f"; }

Sorry for the inconvenience. The changes will most likely be pushed today.

jedahan commented 4 years ago

yeah we should switch back from lazy loading, I thought I tested exec_time but I guess I didn't.

Thanks for the report @barnsza and sorry for breaking it!