# $Revision: 45a6d8582b36 $ $Date: Thu, 14 Mar 2024 21:47:43 -0400 $
# $Source: /doc/html/htdocs/dotfiles/top/dot-zsh/history.zsh $
# $Host: hairball.my.domain $
# $UUID: 704ea02a-ad11-5e34-8878-1b63343038fb $
#
# ZSH command history

export HISTSIZE=2000
export SAVEHIST=2000
export HISTFILE=~/.zsh/.histfile

# Show history without command numbers, look for optional pattern.
unset -f h 2> /dev/null
h () {
    case "$#" in
        0)  fc -ln 1 | less ;;
        *)  fc -ln 1 | grep ${1+"$@"} ;;
    esac
}

# Edit history if I crap it up somehow.  Happens.
unset -f histedit 2> /dev/null
histedit () {
    _x="$HOME/.zsh/.histedit"
    fc -ln 1 > $_x && vi $_x && fc -R $_x && rm $_x
}

# Save a good copy of history.
unset -f savehist 2> /dev/null
savehist () {
    fc -ln 1 >! $HOME/.zsh/.histfile
}
