I recently set up my bash history to collect into an sqlite database. Besides the exact command it records the working directory, return value, starting time, ending time, a shell and a login session id. It doesn't handle background jobs well right now though.

Do you have any links to resources you used to build it or better yet a link to your implementation?

I've been pretty happy with my bash history solution, but thinking about the return value, one big thing I think would be handy would be to have a default filter for searches that removes commands that returned an error code. They might be handy to see every once in a while, but for the most part, I wouldn't want to re-run one of them.

http://pastebin.com/zJkPW79C

I use bash-preexec [1] to hook on the even just before executing a command. I'm kind of nervous if my string quoting is safe though.

[1] https://github.com/rcaloras/bash-preexec