The documentation for promptinit states that themes can install cleanup hooks via prompt_cleanup. > If your function makes any other changes that should > be undone when the theme is disabled, your setup function > may call > > prompt_cleanup command > > where command should be suitably quoted. If your theme > is ever disabled or replaced by another, command is > executed with eval. The documentation also states that: > The precmd and preexec hooks are automatically > adjusted if the prompt theme changes or is disabled. If I understand it correctly, this implies that the following script should print "cleanup" and shouldn't print "hook". autoload -Uz promptinit promptinit prompt_foo_setup() { prompt_cleanup 'print cleanup' precmd_functions+=(hook) } prompt_themes+=(foo) prompt foo prompt off print -r -- $precmd_functions It doesn't print "hello" and does print "hook". I'm attaching a patch that does what I believe the documentation describes. I'm not very confident that I understood the documentation or that my patch is correct. Roman.