99dbf322da1500b6c2e1f23446c58e8c357bd388

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

Merge branch 'set-ls_colors-if-not-available'

Based on #5488.

Diff

 1diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh
 2index 5c5bb0e6d3a3586ba89208bab51256d56b01e448..a3bb24677df9df9ad7db3e5c23a52ce8de8eb9f8 100644
 3--- a/lib/theme-and-appearance.zsh
 4+++ b/lib/theme-and-appearance.zsh
 5@@ -1,36 +1,37 @@
 6 # ls colors
 7 autoload -U colors && colors
 8-export LSCOLORS="Gxfxcxdxbxegedabagacad"
 9 
10 # Enable ls colors
11-if [ "$DISABLE_LS_COLORS" != "true" ]
12-then
13-  # Find the option for using colors in ls, depending on the version: Linux or BSD
14+export LSCOLORS="Gxfxcxdxbxegedabagacad"
15+
16+if [[ "$DISABLE_LS_COLORS" != "true" ]]; then
17+  # Find the option for using colors in ls, depending on the version
18   if [[ "$(uname -s)" == "NetBSD" ]]; then
19     # On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors);
20     # otherwise, leave ls as is, because NetBSD's ls doesn't support -G
21-    gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty'
22+    gls --color -d . &>/dev/null && alias ls='gls --color=tty'
23   elif [[ "$(uname -s)" == "OpenBSD" ]]; then
24     # On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base,
25     # with color and multibyte support) are available from ports.  "colorls"
26     # will be installed on purpose and can't be pulled in by installing
27     # coreutils, so prefer it to "gls".
28-    gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty'
29-    colorls -G -d . &>/dev/null 2>&1 && alias ls='colorls -G'
30+    gls --color -d . &>/dev/null && alias ls='gls --color=tty'
31+    colorls -G -d . &>/dev/null && alias ls='colorls -G'
32   else
33-    ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G'
34+    # For GNU ls, we use the default ls color theme. They can later be overwritten by themes.
35+    if [[ -z "$LS_COLORS" ]]; then
36+      (( $+commands[dircolors] )) && eval "$(dircolors -b)"
37+    fi
38+
39+    ls --color -d . &>/dev/null && alias ls='ls --color=tty' || alias ls='ls -G'
40   fi
41 fi
42 
43 setopt auto_cd
44 setopt multios
45+setopt prompt_subst
46 
47-if [[ x$WINDOW != x ]]
48-then
49-    SCREEN_NO="%B$WINDOW%b "
50-else
51-    SCREEN_NO=""
52-fi
53+[[ -n "$WINDOW" ]] && SCREEN_NO="%B$WINDOW%b " || SCREEN_NO=""
54 
55 # Apply theming defaults
56 PS1="%n@%m:%~%# "
57@@ -40,6 +41,3 @@ ZSH_THEME_GIT_PROMPT_PREFIX="git:("         # Prefix at the very beginning of th
58 ZSH_THEME_GIT_PROMPT_SUFFIX=")"             # At the very end of the prompt
59 ZSH_THEME_GIT_PROMPT_DIRTY="*"              # Text to display if the branch is dirty
60 ZSH_THEME_GIT_PROMPT_CLEAN=""               # Text to display if the branch is clean
61-
62-# Setup the prompt with pretty colors
63-setopt prompt_subst