aboutsummaryrefslogblamecommitdiff
path: root/bash/bashrc.d/hgrep.bash
blob: e5a5d4c903c70a58ddf4097e38c874b7678eb40f (plain) (tree)
1
2
3
4
5
6





                                                                              








                                                     
 
# Search shell history file for a pattern. If you put your whole HISTFILE
# contents into memory, then you probably don't need this, as you can just do:
#
#     $ history | grep PATTERN
#
hgrep() {
    if ! (($#)) ; then
        printf >&2 '%s: Need a pattern\n' "$FUNCNAME"
        exit 2
    fi
    if ! [[ $HISTFILE ]] ; then
        printf >&2 '%s: No HISTFILE\n' "$FUNCNAME"
        exit 2
    fi
    grep "$@" "$HISTFILE"
}