oh-my-zsh.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. if [ -z "$ZSH_COMPDUMP" ]; then
  42. ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
  43. fi
  44. # Load and run compinit
  45. autoload -U compinit
  46. compinit -i -d "${ZSH_COMPDUMP}"
  47. # Load all of the plugins that were defined in ~/.zshrc
  48. for plugin ($plugins); do
  49. if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
  50. source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh
  51. elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
  52. source $ZSH/plugins/$plugin/$plugin.plugin.zsh
  53. fi
  54. done
  55. # Load all of your custom configurations from custom/
  56. for config_file ($ZSH_CUSTOM/*.zsh(N)); do
  57. source $config_file
  58. done
  59. unset config_file
  60. # Load the theme
  61. if [ "$ZSH_THEME" = "random" ]; then
  62. themes=($ZSH/themes/*zsh-theme)
  63. N=${#themes[@]}
  64. ((N=(RANDOM%N)+1))
  65. RANDOM_THEME=${themes[$N]}
  66. source "$RANDOM_THEME"
  67. echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
  68. else
  69. if [ ! "$ZSH_THEME" = "" ]; then
  70. if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then
  71. source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
  72. elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then
  73. source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
  74. else
  75. source "$ZSH/themes/$ZSH_THEME.zsh-theme"
  76. fi
  77. fi
  78. fi