theme-and-appearance.zsh 2.8 KB

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