aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d/grep.bash
diff options
context:
space:
mode:
Diffstat (limited to 'bash/bashrc.d/grep.bash')
-rw-r--r--bash/bashrc.d/grep.bash15
1 files changed, 15 insertions, 0 deletions
diff --git a/bash/bashrc.d/grep.bash b/bash/bashrc.d/grep.bash
new file mode 100644
index 00000000..7cb38c4d
--- /dev/null
+++ b/bash/bashrc.d/grep.bash
@@ -0,0 +1,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)"
+