poetician

oh-my-zsh.sh

Jan 13th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.78 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. is_plugin() {
  33. local base_dir=$1
  34. local name=$2
  35. test -f $base_dir/plugins/$name/$name.plugin.zsh \
  36. || test -f $base_dir/plugins/$name/_$name
  37. }
  38.  
  39. # Add all defined plugins to fpath. This must be done
  40. # before running compinit.
  41. for plugin ($plugins); do
  42. if is_plugin $ZSH_CUSTOM $plugin; then
  43. fpath=($ZSH_CUSTOM/plugins/$plugin $fpath)
  44. elif is_plugin $ZSH $plugin; then
  45. fpath=($ZSH/plugins/$plugin $fpath)
  46. else
  47. echo "[oh-my-zsh] plugin '$plugin' not found"
  48. fi
  49. done
  50.  
  51. # Figure out the SHORT hostname
  52. if [[ "$OSTYPE" = darwin* ]]; then
  53. # macOS's $HOST changes with dhcp, etc. Use ComputerName if possible.
  54. SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST=${HOST/.*/}
  55. else
  56. SHORT_HOST=${HOST/.*/}
  57. fi
  58.  
  59. # Save the location of the current completion dump file.
  60. if [ -z "$ZSH_COMPDUMP" ]; then
  61. ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
  62. fi
  63.  
  64. if [[ $ZSH_DISABLE_COMPFIX != true ]]; then
  65. source $ZSH/lib/compfix.zsh
  66. # If completion insecurities exist, warn the user
  67. handle_completion_insecurities
  68. # Load only from secure directories
  69. compinit -i -C -d "${ZSH_COMPDUMP}"
  70. else
  71. # If the user wants it, load from all found directories
  72. compinit -u -C -d "${ZSH_COMPDUMP}"
  73. fi
  74.  
  75.  
  76. # Load all of the config files in ~/oh-my-zsh that end in .zsh
  77. # TIP: Add files you don't want in git to .gitignore
  78. for config_file ($ZSH/lib/*.zsh); do
  79. custom_config_file="${ZSH_CUSTOM}/lib/${config_file:t}"
  80. [ -f "${custom_config_file}" ] && config_file=${custom_config_file}
  81. source $config_file
  82. done
  83.  
  84. # Load all of the plugins that were defined in ~/.zshrc
  85. for plugin ($plugins); do
  86. if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
  87. source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh
  88. elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
  89. source $ZSH/plugins/$plugin/$plugin.plugin.zsh
  90. fi
  91. done
  92.  
  93. # Load all of your custom configurations from custom/
  94. for config_file ($ZSH_CUSTOM/*.zsh(N)); do
  95. source $config_file
  96. done
  97. unset config_file
  98.  
  99. # Load the theme
  100. if [[ "$ZSH_THEME" == "random" ]]; then
  101. if [[ "${(t)ZSH_THEME_RANDOM_CANDIDATES}" = "array" ]] && [[ "${#ZSH_THEME_RANDOM_CANDIDATES[@]}" -gt 0 ]]; then
  102. themes=($ZSH/themes/${^ZSH_THEME_RANDOM_CANDIDATES}.zsh-theme)
  103. else
  104. themes=($ZSH/themes/*zsh-theme)
  105. fi
  106. N=${#themes[@]}
  107. ((N=(RANDOM%N)+1))
  108. RANDOM_THEME=${themes[$N]}
  109. source "$RANDOM_THEME"
  110. echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
  111. else
  112. if [ ! "$ZSH_THEME" = "" ]; then
  113. if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then
  114. source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
  115. elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then
  116. source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
  117. else
  118. source "$ZSH/themes/$ZSH_THEME.zsh-theme"
  119. fi
  120. fi
  121. fi
Add Comment
Please, Sign In to add comment