Q:

How do you write a script that alerts you in the Terminal like mail's "You have mail"

I guess I'm looking for how to make a script to run whenever you press ENTER in bash, so that it can alert you by echoing a line about some event if an event has occurred. 

A:

You can use the special PROMPT_COMMAND variable, look it up in man bash.
$ PROMPT_COMMAND='echo hello'
hello
$ 
hello
$ 

Set it at the end of ~/.bashrc. I suggest you write a function and call that function in the PROMPT_COMMAND.

