oh-my-zsh.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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) source $config_file
  12. # Set ZSH_CUSTOM to the path where your custom config files
  13. # and plugins exists, or else we will use the default custom/
  14. if [[ -z "$ZSH_CUSTOM" ]]; then
  15. ZSH_CUSTOM="$ZSH/custom"
  16. fi
  17. is_plugin() {
  18. local base_dir=$1
  19. local name=$2
  20. test -f $base_dir/plugins/$name/$name.plugin.zsh \
  21. || test -f $base_dir/plugins/$name/_$name
  22. }
  23. # Add all defined plugins to fpath. This must be done
  24. # before running compinit.
  25. for plugin ($plugins); do
  26. if is_plugin $ZSH_CUSTOM $plugin; then
  27. fpath=($ZSH_CUSTOM/plugins/$plugin $fpath)
  28. elif is_plugin $ZSH $plugin; then
  29. fpath=($ZSH/plugins/$plugin $fpath)
  30. fi
  31. done
  32. # Load and run compinit
  33. autoload -U compinit
  34. compinit -i
  35. # Load all of the plugins that were defined in ~/.zshrc
  36. for plugin ($plugins); do
  37. if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
  38. source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh
  39. elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
  40. source $ZSH/plugins/$plugin/$plugin.plugin.zsh
  41. fi
  42. done
  43. # Load all of your custom configurations from custom/
  44. for config_file ($ZSH_CUSTOM/*.zsh) source $config_file
  45. # Load the theme
  46. if [ "$ZSH_THEME" = "random" ]
  47. then
  48. themes=($ZSH/themes/*zsh-theme)
  49. N=${#themes[@]}
  50. ((N=(RANDOM%N)+1))
  51. RANDOM_THEME=${themes[$N]}
  52. source "$RANDOM_THEME"
  53. echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
  54. else
  55. if [ ! "$ZSH_THEME" = "" ]
  56. then
  57. if [ -f "$ZSH/custom/$ZSH_THEME.zsh-theme" ]
  58. then
  59. source "$ZSH/custom/$ZSH_THEME.zsh-theme"
  60. else
  61. source "$ZSH/themes/$ZSH_THEME.zsh-theme"
  62. fi
  63. fi
  64. fi