Browse Source

Allow loading themes from predefined list

LE Manh Cuong 8 years ago
parent
commit
531c41cdfe
2 changed files with 11 additions and 1 deletions
  1. 5 1
      oh-my-zsh.sh
  2. 6 0
      templates/zshrc.zsh-template

+ 5 - 1
oh-my-zsh.sh

@@ -94,7 +94,11 @@ unset config_file
 
 # Load the theme
 if [ "$ZSH_THEME" = "random" ]; then
-  themes=($ZSH/themes/*zsh-theme)
+  if [ "${(t)ZSH_THEME_RANDOM_CANDICATES}" = "array" ] && [ "${#ZSH_THEME_RANDOM_CANDICATES[@]}" -gt 0 ]; then
+    themes=($ZSH/themes/${^ZSH_THEME_RANDOM_CANDICATES}.zsh-theme)
+  else
+    themes=($ZSH/themes/*zsh-theme)
+  fi
   N=${#themes[@]}
   ((N=(RANDOM%N)+1))
   RANDOM_THEME=${themes[$N]}

+ 6 - 0
templates/zshrc.zsh-template

@@ -7,6 +7,12 @@ export ZSH=$HOME/.oh-my-zsh
 # time that oh-my-zsh is loaded.
 ZSH_THEME="robbyrussell"
 
+# Set list of themes to load
+# Setting this variable when ZSH_THEME=random
+# cause zsh load theme from this variable instead of
+# looking in ~/.oh-my-zsh/themes/
+# ZSH_THEME_RANDOM_CANDICATES=()
+
 # Uncomment the following line to use case-sensitive completion.
 # CASE_SENSITIVE="true"