Using KDE Konsole as a bash terminal I would like to clear the history when I close the terminal (tab/application), note that I do need the bash history when Konsole is still open (to search it); I would like to have it cleared once the terminal is closed.
I often use the terminal for a long time and clear the history before I close the terminal, I am looking for a way to automate the clearing of the history.
I found a similar questions on how to clear the history or how to disable it like How do I close a terminal without saving the history?, however I found nothing helpful for my situation. The difference here is that i do need the history file while the terminal is running, setting
unset HISTFILE disable the history file after that command is ran and does not clear the history file itself. Note that the history file is needed while the session is running but when it get closed it need to be cleared.
How can we clear the bash history when the terminal gets closed?