Clearing bash history on exit of any kind

Nothing fancy here, it is just a reminder of tips already well known:

In ~/.bash_logout

history -c
history -w

In ~/.bashrc

exit_session() {
 . "$HOME/.bash_logout"
}
trap exit_session SIGHUP

alias exit='. "$HOME/.bash_logout" ; exit'

This should cover any case of bash exit, even when you are not actually login out but exiting a terminal/chroot.

Leave a comment