From http://grep.codeconsult.ch/2007/06/29/bash-history-unleashed/

export HISTSIZE=5000
export HISTCONTROL=ignoredups
shopt -s histappend