diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2018-12-11 14:52:11 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2018-12-11 14:52:11 +1300 |
commit | 6e8c6c521ae5d60427634be01b82fe61a79f192b (patch) | |
tree | 5349fc3e9838c69dbb6fd69f0234ea921ea446ea /sh/shrc.d/grep.sh | |
parent | Factor out zsh ENV hack into one file (diff) | |
download | dotfiles-6e8c6c521ae5d60427634be01b82fe61a79f192b.tar.gz dotfiles-6e8c6c521ae5d60427634be01b82fe61a79f192b.zip |
Refactor some conditionals
Diffstat (limited to 'sh/shrc.d/grep.sh')
-rw-r--r-- | sh/shrc.d/grep.sh | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/sh/shrc.d/grep.sh b/sh/shrc.d/grep.sh index 43797ef5..997babc9 100644 --- a/sh/shrc.d/grep.sh +++ b/sh/shrc.d/grep.sh @@ -9,37 +9,43 @@ unset -v GREP_OPTIONS grep() { # Add --binary-files=without-match to gracefully skip binary files - [ -e "$HOME"/.cache/sh/opt/grep/binary-files ] && + if [ -e "$HOME"/.cache/sh/opt/grep/binary-files ] ; then set -- --binary-files=without-match "$@" + fi # Add --color=auto if the terminal has at least 8 colors - [ -e "$HOME"/.cache/sh/opt/grep/color ] && - [ "$({ tput colors||tput Co||echo 0; } 2>/dev/null)" -ge 8 ] && + if [ -e "$HOME"/.cache/sh/opt/grep/color ] && + [ "$({ tput colors||tput Co||echo 0; } 2>/dev/null)" -ge 8 ] ; then set -- --color=auto "$@" + fi # Add --devices=skip to gracefully skip devices - [ -e "$HOME"/.cache/sh/opt/grep/devices ] && + if [ -e "$HOME"/.cache/sh/opt/grep/devices ] ; then set -- --devices=skip "$@" + fi # Add --directories=skip to gracefully skip directories - [ -e "$HOME"/.cache/sh/opt/grep/directories ] && + if [ -e "$HOME"/.cache/sh/opt/grep/directories ] ; then set -- --directories=skip "$@" + fi # Add --exclude to ignore .gitignore and .gitmodules files - [ -e "$HOME"/.cache/sh/opt/grep/exclude ] && + if [ -e "$HOME"/.cache/sh/opt/grep/exclude ] ; then set -- \ --exclude=.gitignore \ --exclude=.gitmodules \ "$@" + fi # Add --exclude-dir to ignore version control dot-directories - [ -e "$HOME"/.cache/sh/opt/grep/exclude-dir ] && + if [ -e "$HOME"/.cache/sh/opt/grep/exclude-dir ] ; then set -- \ --exclude-dir=.cvs \ --exclude-dir=.git \ --exclude-dir=.hg \ --exclude-dir=.svn \ "$@" + fi # Run grep(1) with the concluded arguments command grep "$@" |