The .bash_history
file is a life-save for many of us. Unfortunately, BASH only seems to save the commands of a session when that session is closed (via exit
).
It's a tragedy, then, when all your commands from an important session are vaporized when a session is closed unexpectedly -- before it gets to archive all the commands with fancy syntax that took hours to get right....
This happens to me when I forget to close a SSH connection when leaving work, and it gets disconnected due to inactivity (Write failed: broken pipe
), or when I restart my computer without closing my terminals manually, and so on.
I would love to have my BASH commands archived after some interval -- say every 10 minutes -- so that if I do close a session, my commands will still be there. This seems like something a lot of people might find useful.
Does anyone have an idea of how to do this?
Ideally....
- The functionality would require no extra effort on the user's part once set up -- something he/she could add to
~/.bashrc
- The user could change the backup interval
- It would avoid using temporary files, aliasing
bash
, or other "hacks"
StackOverflow-ers -- consider yourself challenged!