#!/bin/ksh
#
# $Revision: 1.3 $ $Date: 2012-07-26 17:11:47-04 $
# $Source: /home/vogelke/bin/RCS/fixhist,v $
# $Host: sys7.com $
# $UUID: de1b9e4f-57d1-3548-b210-eed52a60a04b $
#
#<fixhist: fix piece-of-shit zsh history file.
#          optional arg: log directory if not under $HOME.

export PATH=/usr/local/bin:/bin:/sbin:/usr/sbin:/usr/bin

case "$#" in
    0) logdir="$HOME/.log" ;;
    *) logdir=$1 ;;
esac

test -d "$logdir" || { echo "$logdir not a directory"; exit 1; }

find $logdir -type f -print |
    egrep -v '/today$' |           # do I need sort after this?
    xargs cat |
    cut -f2 -d'(' |
    cut -f1 -d')' |
    egrep -v '^$|Binary file .* matches|\\M-\^A\^A' |
    uniq

exit 0
