theme-and-appearance.zsh 2.3 KB
Newer Older
1
# ls colors
2
autoload -U colors && colors
3
4

# Enable ls colors
5
6
export LSCOLORS="Gxfxcxdxbxegedabagacad"

7
8
# TODO organise this chaotic logic

9
10
if [[ "$DISABLE_LS_COLORS" != "true" ]]; then
  # 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);
Cosmin Lu?ă's avatar
Cosmin Lu?ă committed
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
17
18
    # On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base,
    # with color and multibyte support) are available from ports.  "colorls"
    # will be installed on purpose and can't be pulled in by installing
19
    # coreutils, so prefer it to "gls".
20
21
    gls --color -d . &>/dev/null && alias ls='gls --color=tty'
    colorls -G -d . &>/dev/null && alias ls='colorls -G'
22
  elif [[ "$OSTYPE" == darwin* ]]; then
23
    # this is a good alias, it works by default just using $LSCOLORS
Eduardo Cuomo's avatar
Eduardo Cuomo committed
24
    ls -G . &>/dev/null && alias ls='ls -G'
25
26
27
28

    # 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'
Cosmin Lu?ă's avatar
Cosmin Lu?ă committed
29
  else
30
    # For GNU ls, we use the default ls color theme. They can later be overwritten by themes.
31
32
33
    if [[ -z "$LS_COLORS" ]]; then
      (( $+commands[dircolors] )) && eval "$(dircolors -b)"
    fi
34

35
    ls --color -d . &>/dev/null && alias ls='ls --color=tty' || { ls -G . &>/dev/null && alias ls='ls -G' }
36
37
38

    # Take advantage of $LS_COLORS for completion as well.
    zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
Cosmin Lu?ă's avatar
Cosmin Lu?ă committed
39
  fi
40
fi
41
42
43

setopt auto_cd
setopt multios
44
setopt prompt_subst
45

46
[[ -n "$WINDOW" ]] && SCREEN_NO="%B$WINDOW%b " || SCREEN_NO=""
47
48

# git theming default: Variables for theming the git info prompt
49
50
51
52
ZSH_THEME_GIT_PROMPT_PREFIX="git:("         # Prefix at the very beginning of the prompt, before the branch name
ZSH_THEME_GIT_PROMPT_SUFFIX=")"             # At the very end of the prompt
ZSH_THEME_GIT_PROMPT_DIRTY="*"              # Text to display if the branch is dirty
ZSH_THEME_GIT_PROMPT_CLEAN=""               # Text to display if the branch is clean