531c41cdfee9e3bbba16d0bf19ca973ad4bb4af5

Author
LE Manh Cuong <cuong.manhle.vn@gmail.com>
Committer
LE Manh Cuong <cuong.manhle.vn@gmail.com>
Date

Message

Allow loading themes from predefined list

Diff

 1diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh
 2index 6cc5ac63023c9d78c4799bf7a3e8a5c255049c3c..0324543d55703f35339842ca4c00ccfa52402938 100644
 3--- a/oh-my-zsh.sh
 4+++ b/oh-my-zsh.sh
 5@@ -94,7 +94,11 @@ unset config_file
 6 
 7 # Load the theme
 8 if [ "$ZSH_THEME" = "random" ]; then
 9-  themes=($ZSH/themes/*zsh-theme)
10+  if [ "${(t)ZSH_THEME_RANDOM_CANDICATES}" = "array" ] && [ "${#ZSH_THEME_RANDOM_CANDICATES[@]}" -gt 0 ]; then
11+    themes=($ZSH/themes/${^ZSH_THEME_RANDOM_CANDICATES}.zsh-theme)
12+  else
13+    themes=($ZSH/themes/*zsh-theme)
14+  fi
15   N=${#themes[@]}
16   ((N=(RANDOM%N)+1))
17   RANDOM_THEME=${themes[$N]}
18diff --git a/templates/zshrc.zsh-template b/templates/zshrc.zsh-template
19index 44e8b0d1bdf18a17a8b494a2219e54c33fe294ea..baedf0675c26d37a8946d32efc628395ad9569c0 100644
20--- a/templates/zshrc.zsh-template
21+++ b/templates/zshrc.zsh-template
22@@ -7,6 +7,12 @@ export ZSH=$HOME/.oh-my-zsh
23 # time that oh-my-zsh is loaded.
24 ZSH_THEME="robbyrussell"
25 
26+# Set list of themes to load
27+# Setting this variable when ZSH_THEME=random
28+# cause zsh load theme from this variable instead of
29+# looking in ~/.oh-my-zsh/themes/
30+# ZSH_THEME_RANDOM_CANDICATES=()
31+
32 # Uncomment the following line to use case-sensitive completion.
33 # CASE_SENSITIVE="true"
34