Eternal Bash history
March 22, 2010
After reading “Bash eternal history” (I think I picked it up via FriendFeed) I put the following lines in my .bashrc file:
export HISTTIMEFORMAT="%s "
PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND ; }"'echo $$ $USER "$(history 1)"|python -c "import sys,time;cli = sys.stdin.read().split(None,4);print \" \".join([cli[0], cli[1], cli[2], time.strftime(\"%Y-%m-%d %H:%M:%S\", time.localtime()), cli[4]])," >> ~/.bash_eternal_history'
The Python bits I added put a human readable timestamp in the file, instead of the standard UNIX timestamp.
Watch out of putting your passwords on the command line!