3 ms·
Yeah, this is how I do it - although I append the hostname to the end of the filename and sync the collection between my machines so that I can grep for history
by 314 7y ago
Yeah, this is how I do it - although I append the hostname to the end of the filename and sync the collection between my machines so that I can grep for history on any machine.
Edit: went to check and apparently I've overcomplicated this somewhat (it's about ten years old) but it is nice if empty lines are not logged. It's an old habit to ctrl-c then hit return repeatedly if a terminal is not responding.
PROMPT_COMMAND=storehist
storehist ()
{
CMDCNT=`history 1 | sed -e 's/\w* *\(.*\)/\1/'`;
if [ "$CMDCNT" != "$LASTCMDIND" ] && [ -n "$LASTCMDIND" ]; then
DATE=`date '+%Y%b%d %H%M'`;
if [ "$LASTCMDIND" != "$CMDCNT" ]; then
echo "$DATE $HOSTNAME:$BASHTTY $CMDCNT" >> ~/.custom_history;
fi;
LASTCMDIND="$CMDCNT";
fi;
LASTCMDIND="$CMDCNT"
}