oh-my-zsh.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # Check for updates on initial load...
  2. if [ "$DISABLE_AUTO_UPDATE" != "true" ]
  3. then
  4. /usr/bin/env ZSH=$ZSH 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. # Load the theme
  50. if [ "$ZSH_THEME" = "random" ]
  51. then
  52. themes=($ZSH/themes/*zsh-theme)
  53. N=${#themes[@]}
  54. ((N=(RANDOM%N)+1))
  55. RANDOM_THEME=${themes[$N]}
  56. source "$RANDOM_THEME"
  57. echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
  58. else
  59. if [ ! "$ZSH_THEME" = "" ]
  60. then
  61. if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]
  62. then
  63. source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
  64. else
  65. source "$ZSH/themes/$ZSH_THEME.zsh-theme"
  66. fi
  67. fi
  68. fi