this runs before commands, not after the whole command line (before prompt is displayed).
my personal bash history tweak suit is based on this.
with a load of complexity of course, because the DEBUG trap is also triggered before each PROMPT_COMMAND commands and on every simple command within the issued command line.
so the above example would record each command of a pipeline separately.
trap 'echo "$BASH_COMMAND" >> ~/.bash_history_extra' DEBUG
this runs before commands, not after the whole command line (before prompt is displayed).
my personal bash history tweak suit is based on this. with a load of complexity of course, because the DEBUG trap is also triggered before each PROMPT_COMMAND commands and on every simple command within the issued command line. so the above example would record each command of a pipeline separately.