diff options
Diffstat (limited to 'bash/bashrc.d/grep.bash')
-rw-r--r-- | bash/bashrc.d/grep.bash | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/bash/bashrc.d/grep.bash b/bash/bashrc.d/grep.bash index dcb27781..656e3c77 100644 --- a/bash/bashrc.d/grep.bash +++ b/bash/bashrc.d/grep.bash @@ -10,13 +10,6 @@ __grepopts() { # Add option to ignore binary files grepopts[${#grepopts[@]}]='-I' - # If the --color option is available and we have a terminal that supports - # at least eight colors, add --color=auto to the options - local -i colors="$(tput colors)" - if [[ "$grephelp" == *--color* ]] && ((colors >= 8)); then - grepopts[${#grepopts[@]}]='--color=auto' - fi - # If the --exclude option is available, exclude some VCS files if [[ "$grephelp" == *--exclude* ]]; then grepopts[${#grepopts[@]}]='--exclude=.git{,ignore,modules}' @@ -27,6 +20,13 @@ __grepopts() { grepopts[${#grepopts[@]}]='--exclude-dir=.{cvs,git,hg,svn}' fi + # If the --color option is available and we have a terminal that supports + # at least eight colors, add --color=auto to the options + local -i colors="$(tput colors)" + if [[ "$grephelp" == *--color* ]] && ((colors >= 8)); then + grepopts[${#grepopts[@]}]='--color=auto' + fi + # Print the options as a single string, space-delimited printf -- "${grepopts[*]}" } |