oh-my-zsh.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # Check for updates on initial load...
  2. if [ "$DISABLE_AUTO_UPDATE" != "true" ]
  3. then
  4. /usr/bin/env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh $ZSH/tools/check_for_upgrade.sh
  5. fi
  6. # Initializes Oh My Zsh
  7. # add a function path
  8. fpath=($ZSH/functions $ZSH/completions $fpath)
  9. # Load all of the config files in ~/oh-my-zsh that end in .zsh
  10. # TIP: Add files you don't want in git to .gitignore
  11. for config_file ($ZSH/lib/*.zsh); do
  12. source $config_file
  13. done
  14. # Set ZSH_CUSTOM to the path where your custom config files
  15. # and plugins exists, or else we will use the default custom/
  16. if [[ -z "$ZSH_CUSTOM" ]]; then
  17. ZSH_CUSTOM="$ZSH/custom"
  18. fi
  19. is_plugin() {
  20. local base_dir=$1
  21. local name=$2
  22. test -f $base_dir/plugins/$name/$name.plugin.zsh \
  23. || test -f $base_dir/plugins/$name/_$name
  24. }
  25. # Add all defined plugins to fpath. This must be done
  26. # before running compinit.
  27. for plugin ($plugins); do
  28. if is_plugin $ZSH_CUSTOM $plugin; then
  29. fpath=($ZSH_CUSTOM/plugins/$plugin $fpath)
  30. elif is_plugin $ZSH $plugin; then
  31. fpath=($ZSH/plugins/$plugin $fpath)
  32. fi
  33. done
  34. # Load and run compinit
  35. autoload -U compinit
  36. compinit -i
  37. # Load all of the plugins that were defined in ~/.zshrc
  38. for plugin ($plugins); do
  39. if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
  40. source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh
  41. elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
  42. source $ZSH/plugins/$plugin/$plugin.plugin.zsh
  43. fi
  44. done
  45. # Load all of your custom configurations from custom/
  46. for config_file ($ZSH_CUSTOM/*.zsh(N)); do
  47. source $config_file
  48. done
  49. unset config_file
  50. # Load the theme
  51. if [ "$ZSH_THEME" = "random" ]
  52. then
  53. themes=($ZSH/themes/*zsh-theme)
  54. N=${#themes[@]}
  55. ((N=(RANDOM%N)+1))
  56. RANDOM_THEME=${themes[$N]}
  57. source "$RANDOM_THEME"
  58. echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
  59. else
  60. if [ ! "$ZSH_THEME" = "" ]
  61. then
  62. if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]
  63. then
  64. source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
  65. elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]
  66. then
  67. source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
  68. else
  69. source "$ZSH/themes/$ZSH_THEME.zsh-theme"
  70. fi
  71. fi
  72. fi