diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2015-05-31 01:15:30 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2015-05-31 01:15:30 +1200 |
commit | 5ccd692805f5978057fffc718bf194be80d5d70f (patch) | |
tree | 3bed55ce57c79f78ab6baabffe27e26fb881ef62 | |
parent | Force integer type on color check (diff) | |
download | dotfiles-5ccd692805f5978057fffc718bf194be80d5d70f.tar.gz dotfiles-5ccd692805f5978057fffc718bf194be80d5d70f.zip |
Consistent color count method
-rw-r--r-- | bash/bashrc.d/grep.bash | 6 | ||||
-rw-r--r-- | bash/bashrc.d/ls.bash | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/bash/bashrc.d/grep.bash b/bash/bashrc.d/grep.bash index 559b5e09..0eedb451 100644 --- a/bash/bashrc.d/grep.bash +++ b/bash/bashrc.d/grep.bash @@ -2,9 +2,11 @@ # set; checks that color is available in the terminal within the function if [[ $GREP_COLORS ]] ; then grep() { - local -i colors=$(tput colors 2>/dev/null) + local -i colors=$( { + tput Co || tput colors + } 2>/dev/null ) if ((colors >= 8)) ; then - command grep --color "$@" + command grep --color=auto "$@" else command grep "$@" fi diff --git a/bash/bashrc.d/ls.bash b/bash/bashrc.d/ls.bash index 5456bf99..7093cd7c 100644 --- a/bash/bashrc.d/ls.bash +++ b/bash/bashrc.d/ls.bash @@ -2,7 +2,9 @@ # checks that color is available in the terminal within the function if [[ $LS_COLORS ]] ; then ls() { - local -i colors=$(tput colors 2>/dev/null) + local -i colors=$( { + tput Co || tput colors + } 2>/dev/null ) if ((colors >= 8)) ; then command ls --color=auto "$@" else |