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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s