Using the PROMPT COMMAND envrionment variable

suggest change

When the last command in an interactive bash instance is done, the evaluated PS1 variable is displayes. Before actually displaying PS1 bash looks whether the PROMPT_COMMAND is set. This value of this var must be a callable program or script. If this var is set this program/script is called BEFORE the PS1 prompt is displayed.

# just a stupid function, we will use to demonstrate
# we check the date if Hour is 12 and Minute is lower than 59
   if (( $(date +%H) == 12 && $(date +%M) < 59 )); then 
      # and print colored \033[ starts the escape sequence 
      # 5; is blinking attribute
      # 2; means bold
      # 31 says red
      printf "\033[5;1;31mmind the lunch break\033[0m\n";
      printf "\033[33mstill working...\033[0m\n"; 

# activating it
export PROMPT_COMMAND=lunchbreak

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents