1# ls colors
2autoload -U colors && colors
3
4# Enable ls colors
5export LSCOLORS="Gxfxcxdxbxegedabagacad"
6
7# TODO organise this chaotic logic
8
9if [[ "$DISABLE_LS_COLORS" != "true" ]]; then
10  # Find the option for using colors in ls, depending on the version
11  if [[ "$OSTYPE" == netbsd* ]]; then
12    # On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors);
13    # otherwise, leave ls as is, because NetBSD's ls doesn't support -G
14    gls --color -d . &>/dev/null && alias ls='gls --color=tty'
15  elif [[ "$OSTYPE" == openbsd* ]]; then
16    # On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base,
17    # with color and multibyte support) are available from ports.  "colorls"
18    # will be installed on purpose and can't be pulled in by installing
19    # coreutils, so prefer it to "gls".
20    gls --color -d . &>/dev/null && alias ls='gls --color=tty'
21    colorls -G -d . &>/dev/null && alias ls='colorls -G'
22  elif [[ "$OSTYPE" == (darwin|freebsd)* ]]; then
23    # this is a good alias, it works by default just using $LSCOLORS
24    ls -G . &>/dev/null && alias ls='ls -G'
25
26    # only use coreutils ls if there is a dircolors customization present ($LS_COLORS or .dircolors file)
27    # otherwise, gls will use the default color scheme which is ugly af
28    [[ -n "$LS_COLORS" || -f "$HOME/.dircolors" ]] && gls --color -d . &>/dev/null && alias ls='gls --color=tty'
29  else
30    # For GNU ls, we use the default ls color theme. They can later be overwritten by themes.
31    if [[ -z "$LS_COLORS" ]]; then
32      (( $+commands[dircolors] )) && eval "$(dircolors -b)"
33    fi
34
35    ls --color -d . &>/dev/null && alias ls='ls --color=tty' || { ls -G . &>/dev/null && alias ls='ls -G' }
36
37    # Take advantage of $LS_COLORS for completion as well.
38    zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
39  fi
40fi
41
42# enable diff color if possible.
43if command diff --color /dev/null /dev/null &>/dev/null; then
44  alias diff='diff --color'
45fi
46
47setopt auto_cd
48setopt multios
49setopt prompt_subst
50
51[[ -n "$WINDOW" ]] && SCREEN_NO="%B$WINDOW%b " || SCREEN_NO=""
52
53# git theming default: Variables for theming the git info prompt
54ZSH_THEME_GIT_PROMPT_PREFIX="git:("         # Prefix at the very beginning of the prompt, before the branch name
55ZSH_THEME_GIT_PROMPT_SUFFIX=")"             # At the very end of the prompt
56ZSH_THEME_GIT_PROMPT_DIRTY="*"              # Text to display if the branch is dirty
57ZSH_THEME_GIT_PROMPT_CLEAN=""               # Text to display if the branch is clean
58ZSH_THEME_RUBY_PROMPT_PREFIX="("
59ZSH_THEME_RUBY_PROMPT_SUFFIX=")"
60