I can trap the exit
command from a gnome-terminal
window using the
Bash trap
command, but it only works if the user types exit
in the terminal window. If the user clicks the close button instead, the trap exit handler is not executed.
Background information:
I would like to save Bash history to a custom history file when the user clicks the close button. I have used export HISTFILE=/tmp/custom.hist
, this works in many cases (when the user clicks the close button in the gnome-terminal, the history is saved to the given file), but in some cases the history is not saved, so I am looking for alternatives to setting the HISTFILE
environment variable..