How preexec and precmd hooks work
masterBash-preexec provides two primary hook functions that emulate Zsh behavior:
preexec: Executed immediately after a command has been read and just before it is executed. The command string typed by the user is passed as the first argument ($1).precmd: Executed just before each prompt is displayed. This is a more flexible and resilient alternative to the standardPROMPT_COMMAND.
If these functions are defined in your environment, bash-preexec will automatically invoke them.
source ~/.bash-preexec.sh
preexec() { echo "just typed $1"; }
precmd() { echo "printing the prompt"; }