oh-my-zsh.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. # Figure out the SHORT hostname
  35. if [ -n "$commands[scutil]" ]; then
  36. # OS X
  37. SHORT_HOST=$(scutil --get ComputerName)
  38. else
  39. SHORT_HOST=${HOST/.*/}
  40. fi
  41. # Save the location of the current completion dump file.
  42. ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
  43. # Load and run compinit
  44. autoload -U compinit
  45. compinit -i -d "${ZSH_COMPDUMP}"
  46. # Load all of the plugins that were defined in ~/.zshrc
  47. for plugin ($plugins); do
  48. if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
  49. source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh
  50. elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
  51. source $ZSH/plugins/$plugin/$plugin.plugin.zsh
  52. fi
  53. done
  54. # Load all of your custom configurations from custom/
  55. for config_file ($ZSH_CUSTOM/*.zsh(N)); do
  56. source $config_file
  57. done
  58. unset config_file
  59. # Load the theme
  60. if [ "$ZSH_THEME" = "random" ]
  61. 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" = "" ]
  70. then
  71. if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]
  72. then
  73. source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
  74. elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]
  75. then
  76. source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
  77. else
  78. source "$ZSH/themes/$ZSH_THEME.zsh-theme"
  79. fi
  80. fi
  81. fi