diff options
-rw-r--r-- | sh/shrc.d/grep.sh | 48 | ||||
-rw-r--r-- | sh/shrc.d/ls.sh | 21 |
2 files changed, 35 insertions, 34 deletions
diff --git a/sh/shrc.d/grep.sh b/sh/shrc.d/grep.sh index 6fef7701..2ccaed69 100644 --- a/sh/shrc.d/grep.sh +++ b/sh/shrc.d/grep.sh @@ -5,14 +5,22 @@ # Define function proper grep() { - # Add --exclude-dir to ignore version control dot-directories - [ -e "$HOME"/.cache/grep/exclude-dir ] && - set -- \ - --exclude-dir=.cvs \ - --exclude-dir=.git \ - --exclude-dir=.hg \ - --exclude-dir=.svn \ - "$@" + # Add --binary-files=without-match to gracefully skip binary files + [ -e "$HOME"/.cache/grep/binary-files ] && + set -- --binary-files=without-match "$@" + + # 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 --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 ] && @@ -21,22 +29,14 @@ grep() { --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 "$@" + # Add --exclude-dir to ignore version control dot-directories + [ -e "$HOME"/.cache/grep/exclude-dir ] && + set -- \ + --exclude-dir=.cvs \ + --exclude-dir=.git \ + --exclude-dir=.hg \ + --exclude-dir=.svn \ + "$@" # Run grep(1) with the concluded arguments command grep "$@" diff --git a/sh/shrc.d/ls.sh b/sh/shrc.d/ls.sh index 57f6ed24..8fd42431 100644 --- a/sh/shrc.d/ls.sh +++ b/sh/shrc.d/ls.sh @@ -5,22 +5,23 @@ # Define function proper ls() { - # Add --time-style='+%Y-%m-%d %H:%M:%S' to show trailing indicators of the filetype - [ -e "$HOME"/.cache/ls/time-style ] && - set -- --time-style='+%Y-%m-%d %H:%M:%S' "$@" + # Add --block-size=K to always show the filesize in kibibytes + [ -e "$HOME"/.cache/ls/block-size ] && + set -- --block-size=K "$@" + + # Add --classify to show trailing indicators of the filetype + [ -e "$HOME"/.cache/ls/classify ] && + set -- --classify "$@" # Add --color if the terminal has at least 8 colors [ -e "$HOME"/.cache/ls/color ] && [ "$({ tput colors || tput Co ; } 2>/dev/null)" -ge 8 ] && set -- --color=auto "$@" - # Add --classify to show trailing indicators of the filetype - [ -e "$HOME"/.cache/ls/classify ] && - set -- --classify "$@" - - # Add --block-size=K to always show the filesize in kibibytes - [ -e "$HOME"/.cache/ls/block-size ] && - set -- --block-size=K "$@" + # Add --time-style='+%Y-%m-%d %H:%M:%S' to show trailing indicators of the + # filetype + [ -e "$HOME"/.cache/ls/time-style ] && + set -- --time-style='+%Y-%m-%d %H:%M:%S' "$@" # Run ls(1) with the concluded arguments command ls "$@" |