aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d/grep.bash
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2013-06-20 22:51:35 +1200
committerTom Ryder <tom@sanctum.geek.nz>2013-06-20 22:51:35 +1200
commitbebbc9bb1c32f3f460ca6d6e81446fcc996dc9d6 (patch)
treeb10dfe3d6269550146c4d1184921f379cd79af83 /bash/bashrc.d/grep.bash
parentNix DISPLAY, otherwise don't change environment (diff)
downloaddotfiles-bebbc9bb1c32f3f460ca6d6e81446fcc996dc9d6.tar.gz
dotfiles-bebbc9bb1c32f3f460ca6d6e81446fcc996dc9d6.zip
Massive overhaul of structure for Bash files
* No longer using .bash_logout * No longer using .bash_profile, using POSIX-compliant .profile * instead; in particular, moved most of environment settings into .profile * Moved some of the separable functionality of both .profile and .bashrc into subdirectories (some scripts shared, some not) * Tidied implementation of ls/grep aliases * Updated install script to reflect all of the above
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)"
+