uses zsh's hook function.
http://zsh.sourceforge.net/Doc/Release/Functions.html#Hook-Functions