From 9d0851ed95d705e436a2683b92cbaa412772e04c Mon Sep 17 00:00:00 2001 From: Eric Nielsen Date: Fri, 1 Dec 2017 07:33:55 -0500 Subject: [PATCH] [utility] Use "our" ls colors in GNU too They were only being applied to BSD. Also, GNU uses `LS_COLORS`, and BSD only uses `LSCOLORS`. Keeping these consistent, with same color scheme, in both GNU and BSD. Simplify arithmetic command expression without using `${var}` substitution, but `var` instead. The second construct does not fail if `var` is not defined, but defaults its value to `0` in that case. --- modules/utility/init.zsh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/utility/init.zsh b/modules/utility/init.zsh index e4ce9d8..91db5bd 100644 --- a/modules/utility/init.zsh +++ b/modules/utility/init.zsh @@ -6,14 +6,16 @@ # Colours # -if [[ ! -z ${terminfo[colors]} ]] && (( ${terminfo[colors]} >= 8 )); then +if (( terminfo[colors] >= 8 )); then + # ls Colours if (( ${+commands[dircolors]} )); then # GNU - if [[ -s ${HOME}/.dir_colors ]]; then + + (( ! ${+LS_COLORS} )) && if [[ -s ${HOME}/.dir_colors ]]; then eval "$(dircolors --sh ${HOME}/.dir_colors)" else - eval "$(dircolors --sh)" + export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=1;36:cd=1;33:su=30;41:sg=30;46:tw=30;42:ow=30;43' fi alias ls='ls --group-directories-first --color=auto' @@ -21,12 +23,10 @@ if [[ ! -z ${terminfo[colors]} ]] && (( ${terminfo[colors]} >= 8 )); then else # BSD - # colours for ls and completion (( ! ${+LSCOLORS} )) && export LSCOLORS='exfxcxdxbxGxDxabagacad' - (( ! ${+LS_COLORS} )) && export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=36;01:cd=33;01:su=31;40;07:sg=36;40;07:tw=32;40;07:ow=33;40;07:' # stock OpenBSD ls does not support colors at all, but colorls does. - if [[ $OSTYPE == openbsd* ]]; then + if [[ ${OSTYPE} == openbsd* ]]; then if (( ${+commands[colorls]} )); then alias ls='colorls -G' fi