not mine (i stole it from someone else) but very useful bash prompt_func to store your entire bash history forever:
8<-----------------------------
function prompt_func {
CMDNUM=`history 1 | awk '{print $1}'`
LAST_CMD=`history 1 | cut -f 3- -d ' '`
if [ x$LAST_CMDNUM = xwho_knows ]; then
LAST_CMDNUM=$CMDNUM
fi
if [ x$CMDNUM != x$LAST_CMDNUM ]; then
FULL_CMD_LOG="$HOME/full-history/$(date "+%Y-%m-%d").log"
echo "$(date '+%H:%M:%S') `munge_pwd` $LAST_CMD" >> $FULL_CMD_LOG
LAST_CMDNUM=$CMDNUM
fi
}
export PROMPT_COMMAND=prompt_func
export LAST_CMDNUM=who_knows
function fh() {
grep -r --color=NEVER ${*} ~/full-history |
sed 's/[^ ]* //' |
sed 's/ \[[^]]\*\]/$/'
}
8<-----------------------------
`munge_pwd` is another script that does various substitutions on the prompt (specific to how my work directories are laid out) but mostly you can just substitute `pwd` if you don't care about deduplicating stuff like multiple checkouts of the same project.
8<-----------------------------
8<-----------------------------`munge_pwd` is another script that does various substitutions on the prompt (specific to how my work directories are laid out) but mostly you can just substitute `pwd` if you don't care about deduplicating stuff like multiple checkouts of the same project.