Can you use a zsh hook instead?

https://gist.github.com/OliverJAsh/832d49faf47ed7b0fc51#file-gistfile1-sh-L64