blob: 62acdb01fc9d8859a399e73125c8be546bcac267 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# Function returns calculated options for grep
__grepopts() {
local grepopts='-I'
local grephelp="$(grep --help 2>/dev/null)"
if [[ "$grephelp" == *--color* ]]; then
grepopts="${grepopts} --color=auto"
fi
if [[ "$grephelp" == *--exclude* ]]; then
grepopts="${grepopts} --exclude=.git{,ignore,modules}"
fi
if [[ "$grephelp" == *--exclude-dir* ]]; then
grepopts="${grepopts} --exclude-dir=.{cvs,git,hg,svn}"
fi
printf '%s' "$grepopts"
}
# Alias grep with those options
alias grep="grep $(__grepopts)"
# Unset helper function
unset __grepopts
|