Created by: hcgraf
This is just a rebase of the previous PR #355 by @stonewareslord on top of develop.
Additionally, I made it actually work by using precmd/preexec *_functions arrays instead of just as single function (which would be overwritten by prompt_off/prompt_on)