LinOnetwo

oh-my-zsh.sh

May 6th, 2019
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.75 KB | None | 0 0
  1. # Set ZSH_CACHE_DIR to the path where cache files should be created
  2. # or else we will use the default cache/
  3. if [[ -z "$ZSH_CACHE_DIR" ]]; then
  4.   ZSH_CACHE_DIR="$ZSH/cache"
  5. fi
  6.  
  7. # Migrate .zsh-update file to $ZSH_CACHE_DIR
  8. if [ -f ~/.zsh-update ] && [ ! -f ${ZSH_CACHE_DIR}/.zsh-update ]; then
  9.     mv ~/.zsh-update ${ZSH_CACHE_DIR}/.zsh-update
  10. fi
  11.  
  12. # Check for updates on initial load...
  13. if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then
  14.   env ZSH=$ZSH ZSH_CACHE_DIR=$ZSH_CACHE_DIR DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh
  15. fi
  16.  
  17. # Initializes Oh My Zsh
  18.  
  19. # add a function path
  20. fpath=($ZSH/functions $ZSH/completions $fpath)
  21.  
  22. # Load all stock functions (from $fpath files) called below.
  23. autoload -U compaudit compinit
  24.  
  25. # Set ZSH_CUSTOM to the path where your custom config files
  26. # and plugins exists, or else we will use the default custom/
  27. if [[ -z "$ZSH_CUSTOM" ]]; then
  28.     ZSH_CUSTOM="$ZSH/custom"
  29. fi
  30.  
  31.  
  32. # Load all of the config files in ~/oh-my-zsh that end in .zsh
  33. # TIP: Add files you don't want in git to .gitignore
  34. for config_file ($ZSH/lib/*.zsh); do
  35.   custom_config_file="${ZSH_CUSTOM}/lib/${config_file:t}"
  36.   [ -f "${custom_config_file}" ] && config_file=${custom_config_file}
  37.   source $config_file
  38. done
  39.  
  40.  
  41. is_plugin() {
  42.   local base_dir=$1
  43.   local name=$2
  44.   test -f $base_dir/plugins/$name/$name.plugin.zsh \
  45.     || test -f $base_dir/plugins/$name/_$name
  46. }
  47.  
  48. # Add all defined plugins to fpath. This must be done
  49. # before running compinit.
  50. for plugin ($plugins); do
  51.   if is_plugin $ZSH_CUSTOM $plugin; then
  52.     fpath=($ZSH_CUSTOM/plugins/$plugin $fpath)
  53.   elif is_plugin $ZSH $plugin; then
  54.     fpath=($ZSH/plugins/$plugin $fpath)
  55.   else
  56.     echo "[oh-my-zsh] plugin '$plugin' not found"
  57.   fi
  58. done
  59.  
  60. # Figure out the SHORT hostname
  61. if [[ "$OSTYPE" = darwin* ]]; then
  62.   # macOS's $HOST changes with dhcp, etc. Use ComputerName if possible.
  63.   SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST=${HOST/.*/}
  64. else
  65.   SHORT_HOST=${HOST/.*/}
  66. fi
  67.  
  68. # Save the location of the current completion dump file.
  69. if [ -z "$ZSH_COMPDUMP" ]; then
  70.   ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
  71. fi
  72.  
  73. if [[ $ZSH_DISABLE_COMPFIX != true ]]; then
  74.   # If completion insecurities exist, warn the user
  75.   handle_completion_insecurities
  76.   # Load only from secure directories
  77.   compinit -i -C -d "${ZSH_COMPDUMP}"
  78. else
  79.   # If the user wants it, load from all found directories
  80.   compinit -u -C -d "${ZSH_COMPDUMP}"
  81. fi
  82.  
  83. # Load all of the plugins that were defined in ~/.zshrc
  84. for plugin ($plugins); do
  85.   if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
  86.     source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh
  87.   elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
  88.     source $ZSH/plugins/$plugin/$plugin.plugin.zsh
  89.   fi
  90. done
  91.  
  92. # Load all of your custom configurations from custom/
  93. for config_file ($ZSH_CUSTOM/*.zsh(N)); do
  94.   source $config_file
  95. done
  96. unset config_file
  97.  
  98. # Load the theme
  99. if [[ "$ZSH_THEME" == "random" ]]; then
  100.   if [[ "${(t)ZSH_THEME_RANDOM_CANDIDATES}" = "array" ]] && [[ "${#ZSH_THEME_RANDOM_CANDIDATES[@]}" -gt 0 ]]; then
  101.     themes=($ZSH/themes/${^ZSH_THEME_RANDOM_CANDIDATES}.zsh-theme)
  102.   else
  103.     themes=($ZSH/themes/*zsh-theme)
  104.   fi
  105.   N=${#themes[@]}
  106.   ((N=(RANDOM%N)+1))
  107.   RANDOM_THEME=${themes[$N]}
  108.   source "$RANDOM_THEME"
  109.   echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
  110. else
  111.   if [ ! "$ZSH_THEME" = ""  ]; then
  112.     if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then
  113.       source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
  114.     elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then
  115.       source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
  116.     else
  117.       source "$ZSH/themes/$ZSH_THEME.zsh-theme"
  118.     fi
  119.   fi
  120. fi
Advertisement
Add Comment
Please, Sign In to add comment