theme-and-appearance.zsh 2.5 KB

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