oh-my-zsh.sh 2.7 KB

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