From f7e851d9986a30e3d590d67b23e862a38d427472 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 21 Aug 2016 13:09:10 +1200 Subject: Clean up/extend grep()/ls() extension --- sh/shrc.d/grep.sh | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'sh/shrc.d/grep.sh') diff --git a/sh/shrc.d/grep.sh b/sh/shrc.d/grep.sh index 2f360716..6fef7701 100644 --- a/sh/shrc.d/grep.sh +++ b/sh/shrc.d/grep.sh @@ -5,30 +5,6 @@ # Define function proper grep() { - # Add --color if the terminal has at least 8 colors - [ -e "$HOME"/.cache/grep/color ] && - [ "$({ tput colors || tput Co ; } 2>/dev/null)" -ge 8 ] && - set -- --color=auto "$@" - - # Add --binary-files=without-match to gracefully skip binary files - [ -e "$HOME"/.cache/grep/binary-files ] && - set -- --binary-files=without-match "$@" - - # Add --devices=skip to gracefully skip devices - [ -e "$HOME"/.cache/grep/devices ] && - set -- --devices=skip "$@" - - # Add --directories=skip to gracefully skip directories - [ -e "$HOME"/.cache/grep/directories ] && - set -- --directories=skip "$@" - - # Add --exclude to ignore .gitignore and .gitmodules files - [ -e "$HOME"/.cache/grep/exclude ] && - set -- \ - --exclude=.gitignore \ - --exclude=.gitmodules \ - "$@" - # Add --exclude-dir to ignore version control dot-directories [ -e "$HOME"/.cache/grep/exclude-dir ] && set -- \ @@ -38,6 +14,30 @@ grep() { --exclude-dir=.svn \ "$@" + # Add --exclude to ignore .gitignore and .gitmodules files + [ -e "$HOME"/.cache/grep/exclude ] && + set -- \ + --exclude=.gitignore \ + --exclude=.gitmodules \ + "$@" + + # Add --directories=skip to gracefully skip directories + [ -e "$HOME"/.cache/grep/directories ] && + set -- --directories=skip "$@" + + # Add --devices=skip to gracefully skip devices + [ -e "$HOME"/.cache/grep/devices ] && + set -- --devices=skip "$@" + + # Add --color if the terminal has at least 8 colors + [ -e "$HOME"/.cache/grep/color ] && + [ "$({ tput colors || tput Co ; } 2>/dev/null)" -ge 8 ] && + set -- --color=auto "$@" + + # Add --binary-files=without-match to gracefully skip binary files + [ -e "$HOME"/.cache/grep/binary-files ] && + set -- --binary-files=without-match "$@" + # Run grep(1) with the concluded arguments command grep "$@" } -- cgit v1.2.3