Introducing how to execute commands after running a command in Bash on the command line of Linux computers and servers.
The value of $PROMPT_COMMAND is executed as a command before the prompt is updated with PS1. In other words, itโs executed after command execution.
export PROMPT_COMMAND="echo y"
Concrete example
command line - How to share history between terminal tabs? - Ask Different
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
Note that when you start bash from bash, .bashrc is loaded multiple times, and in that case, initialization processing is necessary.
Itโs good to write export PROMPT_COMMAND= near the beginning of .bashrc.