blob: 52570ea21b6300fb88be9ec588f4ad80cc99120e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# Define function wrapper for grep(1) with --color option if GREP_COLORS is
# set; checks that color is available in the terminal within the function
if [[ ! -n $GREP_COLORS ]] ; then
return
fi
# Define function proper
grep() {
local -i colors=$( {
tput Co || tput colors
} 2>/dev/null )
if ((colors >= 8)) ; then
command grep --color=auto "$@"
else
command grep "$@"
fi
}
|