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