shopt -s histappend
export PROMPT_COMMAND='history -a'
The histappend option appends to history instead of overwriting. PROMPT_COMMAND is run before bash displays a prompt -- this will save each command right after you issue it, instead of when you exit the session.Now that your history is about to get a lot larger, you'd probably want to override the defaults for HISTSIZE and HISTFILESIZE.
Somewhat OT, but since I mentioned PROMPT_COMMAND: One very useful piece of info to have in your prompt is the exit status of your last command. You can do that with
export PROMPT_COMMAND='ERRVAL=$?; history -a'
Then just include ${ERRVAL} in your PS1.