oh-my-zsh.sh 2.4 KB

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