aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d/grep.bash
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2013-07-30 17:13:49 +1200
committerTom Ryder <tom@sanctum.geek.nz>2013-07-30 17:13:49 +1200
commita2cac0511b53ba375e259a655fa17c0189fca22c (patch)
treeed1a7fb69ba9875e647efc881d9e01b4a8b8fcdb /bash/bashrc.d/grep.bash
parentUnset Fedora settings I dislike (diff)
downloaddotfiles-a2cac0511b53ba375e259a655fa17c0189fca22c.tar.gz
dotfiles-a2cac0511b53ba375e259a655fa17c0189fca22c.zip
Fix grep/ls aliasing for efficiency/correctness
Avoiding the use of echo, using builtins whereever possible
Diffstat (limited to 'bash/bashrc.d/grep.bash')
-rw-r--r--bash/bashrc.d/grep.bash10
1 files changed, 5 insertions, 5 deletions
diff --git a/bash/bashrc.d/grep.bash b/bash/bashrc.d/grep.bash
index ea75bd8e..ee1bd386 100644
--- a/bash/bashrc.d/grep.bash
+++ b/bash/bashrc.d/grep.bash
@@ -1,14 +1,14 @@
# Function returns calculated options for grep
__grepopts() {
local grepopts='-I'
- local grephelp=$(grep --help)
- echo $grephelp | grep -- --color &>/dev/null \
+ local grephelp=$(grep --help 2>/dev/null)
+ [[ "$grephelp" == *--color* ]] \
&& grepopts="${grepopts} --color=auto"
- echo $grephelp | grep -- --exclude &>/dev/null \
+ [[ "$grephelp" == *--exclude* ]] \
&& grepopts="${grepopts} --exclude=.git{,ignore,modules}"
- echo $grephelp | grep -- --exclude-dir &>/dev/null \
+ [[ "$grephelp" == *--exclude-dir* ]] \
&& grepopts="${grepopts} --exclude-dir=.{cvs,git,hg,svn}"
- echo $grepopts
+ printf '%s' $grepopts
}
# Alias grep with those options