How to run some command before or after every Bash command entered from console?

As l0b0 suggests, you can use PROMPT_COMMAND to do your second request and you won’t have to touch PS1.

To do your first request, you can trap the DEBUG pseudo-signal:

trap 'echo "foobar"' DEBUG

Leave a Comment