From 1b799e9762067f912c0eb807cd5a55d8f122adfd Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 2 Nov 2016 15:39:28 +0100 Subject: Check dircolors settings before using gls on darwin (#5570) `gls` seems to be installed by default or on most macOS systems, but its default color scheme sucks. This fix will make sure to only use it if it has been customised prior to running OMZ. Related: #5516, #5520. --- lib/theme-and-appearance.zsh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib/theme-and-appearance.zsh') diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 467b770d6..122e3fecb 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -4,6 +4,8 @@ autoload -U colors && colors # Enable ls colors export LSCOLORS="Gxfxcxdxbxegedabagacad" +# TODO organise this chaotic logic + if [[ "$DISABLE_LS_COLORS" != "true" ]]; then # Find the option for using colors in ls, depending on the version if [[ "$OSTYPE" == netbsd* ]]; then @@ -18,7 +20,12 @@ if [[ "$DISABLE_LS_COLORS" != "true" ]]; then gls --color -d . &>/dev/null && alias ls='gls --color=tty' colorls -G -d . &>/dev/null && alias ls='colorls -G' elif [[ "$OSTYPE" == darwin* ]]; then - gls --color -d . &>/dev/null && alias ls='gls --color=tty' || alias ls='ls -G' + # this is a good alias, it works by default just using $LSCOLORS + alias ls='ls -G' + + # only use coreutils ls if there is a dircolors customization present ($LS_COLORS or .dircolors file) + # otherwise, gls will use the default color scheme which is ugly af + [[ -n "$LS_COLORS" || -f "$HOME/.dircolors" ]] && gls --color -d . &>/dev/null && alias ls='gls --color=tty' else # For GNU ls, we use the default ls color theme. They can later be overwritten by themes. if [[ -z "$LS_COLORS" ]]; then -- cgit v1.2.3-70-g09d2 From 40544a1d5d1a55f88c226213fe464ede8b454fec Mon Sep 17 00:00:00 2001 From: Eduardo Cuomo Date: Sun, 10 Apr 2016 13:20:59 -0300 Subject: Fix invalid "ls -G" alias. --- lib/theme-and-appearance.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/theme-and-appearance.zsh') diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 122e3fecb..f368a48f0 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -21,7 +21,7 @@ if [[ "$DISABLE_LS_COLORS" != "true" ]]; then colorls -G -d . &>/dev/null && alias ls='colorls -G' elif [[ "$OSTYPE" == darwin* ]]; then # this is a good alias, it works by default just using $LSCOLORS - alias ls='ls -G' + ls -G . &>/dev/null && alias ls='ls -G' # only use coreutils ls if there is a dircolors customization present ($LS_COLORS or .dircolors file) # otherwise, gls will use the default color scheme which is ugly af @@ -32,7 +32,7 @@ if [[ "$DISABLE_LS_COLORS" != "true" ]]; then (( $+commands[dircolors] )) && eval "$(dircolors -b)" fi - ls --color -d . &>/dev/null && alias ls='ls --color=tty' || alias ls='ls -G' + ls --color -d . &>/dev/null && alias ls='ls --color=tty' || ls -G . &>/dev/null && alias ls='ls -G' # Take advantage of $LS_COLORS for completion as well. zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" -- cgit v1.2.3-70-g09d2 From 0b340bc3a5c58609a07987b296f773eaea17b274 Mon Sep 17 00:00:00 2001 From: "mingang.he" Date: Thu, 3 Nov 2016 21:10:08 +0800 Subject: Fix #5604: No DIR ( directory ) colors (#5605) --- lib/theme-and-appearance.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/theme-and-appearance.zsh') diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index f368a48f0..96f34aa81 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -32,7 +32,7 @@ if [[ "$DISABLE_LS_COLORS" != "true" ]]; then (( $+commands[dircolors] )) && eval "$(dircolors -b)" fi - ls --color -d . &>/dev/null && alias ls='ls --color=tty' || ls -G . &>/dev/null && alias ls='ls -G' + ls --color -d . &>/dev/null && alias ls='ls --color=tty' || { ls -G . &>/dev/null && alias ls='ls -G' } # Take advantage of $LS_COLORS for completion as well. zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" -- cgit v1.2.3-70-g09d2