rupa / z

z - jump around
Do What The F*ck You Want To Public License
16.39k stars 1.17k forks source link

On ZSH hook to chpwd via add-zsh-hook #210

Closed z0rc closed 6 years ago

z0rc commented 7 years ago

What's the point of hooking to precmd while ZSH provides chpwd hook that's called on directory change?

Also instead of doing own magic trying to make _z_precmd to be added only once precmd_functions it's better to use add-zsh-hook.

rupa commented 7 years ago

I don't use zsh, most of the code for zsh was proposed or pull requested by others - happy to look at any proposals. Using chpwd seems like an improvement.

My main concern with any changes is that there's much more configurables and differences between versions going on with zsh - not looking forward to dealing with it if e.g. chpwd hook doesn't exist in old versions - as I'm not a zsh expert, or user

ericbn commented 7 years ago

The zsh release notes don't say anything about the chpwd hook or add-zsh-hook. Looking at the commit history: add-zsh-hook was introduced in zsh 4.3.4, 10 years ago. The chpwd hook exists at least since zsh 3.1.7, 18 years ago (probably this hook was introduced together with precmd and the others, also not even sure if the current way z is setting up the hook is compatible with that version).

@rupa, how far do you want to support zsh? Versions >= 5.0 are already supported in most distributions (see this discussion), which means using both the chpwd hook and add-zsh-hook is more than safe in this case.

rupa commented 6 years ago

gonna close this. per discussion on another issue - the problem of chpwd is that we are (and want to continue) weighting by "time spent" in a directory, not how many times you've visited