aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d/grep.bash
blob: 7cb38c4d7c4e31525be367b9f356b110f7c205ff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Function returns calculated options for grep
function __grepopts {
    local grepopts='-I'
    grep --help | grep -- --color &>/dev/null \
        && grepopts="${grepopts} --color=auto"
    grep --help | grep -- --exclude &>/dev/null \
        && grepopts="${grepopts} --exclude=.git{,ignore,modules}"
    grep --help | grep -- --exclude-dir &>/dev/null \
        && grepopts="${grepopts} --exclude-dir=.{cvs,git,hg,svn}"
    echo $grepopts
}

# Alias grep with those options
alias grep="grep $(__grepopts)"