diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2013-08-18 23:40:25 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2013-08-18 23:40:25 +1200 |
commit | 79381336a95358d4814df0193feda2f262ce805f (patch) | |
tree | 55fbbacd9c7a41bbf763439dc207932e39b8904c /bash | |
parent | Use arrays to collect options for ls/grep aliases (diff) | |
download | dotfiles-79381336a95358d4814df0193feda2f262ce805f.tar.gz dotfiles-79381336a95358d4814df0193feda2f262ce805f.zip |
Use arithmetic expression for color space tests
Diffstat (limited to 'bash')
-rw-r--r-- | bash/bashrc.d/grep.bash | 3 | ||||
-rw-r--r-- | bash/bashrc.d/ls.bash | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/bash/bashrc.d/grep.bash b/bash/bashrc.d/grep.bash index da391193..942bb9af 100644 --- a/bash/bashrc.d/grep.bash +++ b/bash/bashrc.d/grep.bash @@ -3,7 +3,8 @@ __grepopts() { local -a grepopts local grephelp="$(grep --help 2>/dev/null)" grepopts[${#grepopts[@]}]='-I' - if [[ "$grephelp" == *--color* && "$(tput colors)" -ge 8 ]]; then + local -i colors="$(tput colors)" + if [[ "$grephelp" == *--color* ]] && ((colors >= 8)); then grepopts[${#grepopts[@]}]='--color=auto' fi if [[ "$grephelp" == *--exclude* ]]; then diff --git a/bash/bashrc.d/ls.bash b/bash/bashrc.d/ls.bash index 9446c56e..44092d85 100644 --- a/bash/bashrc.d/ls.bash +++ b/bash/bashrc.d/ls.bash @@ -2,7 +2,8 @@ __lsopts() { local -a lsopts local lshelp="$(ls --help 2>/dev/null)" - if [[ "$lshelp" == *--color* && "$(tput colors)" -ge 8 ]]; then + local -i colors="$(tput colors)" + if [[ "$lshelp" == *--color* ]] && ((colors >= 8)); then lsopts[${#lsopts[@]}]='--color=auto' fi printf -- "${lsopts[*]}" |