0c28e392ebbcf7b67bc34296b33d087de900a48d

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge branch 'Gnouc-Random_Theme_From_List'

Diff

 1diff --git a/README.md b/README.md
 2index 54107b1cb6ebc809293e6308f9785050de183305..fd4a0abc05151a947115af8c4a7348543a9a97e6 100644
 3--- a/README.md
 4+++ b/README.md
 5@@ -96,6 +96,14 @@ If you're feeling feisty, you can let the computer select one randomly for you e
 6 ZSH_THEME="random" # (...please let it be pie... please be some pie..)
 7 ```
 8 
 9+And if you want to pick random theme from a list of your favorite themes:
10+
11+```shell
12+ZSH_THEM_RANDOM_CANDIDATES=(
13+  "robbyrussell"
14+  "agnoster"
15+)
16+```
17 
18 ## Advanced Topics
19 
20diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh
21index a7de646f28c291119ce0efa5060fd002fd0e78b6..7f78e4140da5ccae7094572ed34908e9359b571c 100644
22--- a/oh-my-zsh.sh
23+++ b/oh-my-zsh.sh
24@@ -93,8 +93,12 @@ done
25 unset config_file
26 
27 # Load the theme
28-if [ "$ZSH_THEME" = "random" ]; then
29-  themes=($ZSH/themes/*zsh-theme)
30+if [[ "$ZSH_THEME" == "random" ]]; then
31+  if [[ "${(t)ZSH_THEME_RANDOM_CANDIDATES}" = "array" ]] && [[ "${#ZSH_THEME_RANDOM_CANDIDATES[@]}" -gt 0 ]]; then
32+    themes=($ZSH/themes/${^ZSH_THEME_RANDOM_CANDIDATES}.zsh-theme)
33+  else
34+    themes=($ZSH/themes/*zsh-theme)
35+  fi
36   N=${#themes[@]}
37   ((N=(RANDOM%N)+1))
38   RANDOM_THEME=${themes[$N]}
39diff --git a/templates/zshrc.zsh-template b/templates/zshrc.zsh-template
40index af42e5b9f344f5694cdefaa99019deb01cba0c1e..966d7a9758bda438762262a8491100361880928d 100644
41--- a/templates/zshrc.zsh-template
42+++ b/templates/zshrc.zsh-template
43@@ -9,6 +9,13 @@ export ZSH=$HOME/.oh-my-zsh
44 # See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
45 ZSH_THEME="robbyrussell"
46 
47+# Set list of themes to load
48+# Setting this variable when ZSH_THEME=random
49+# cause zsh load theme from this variable instead of
50+# looking in ~/.oh-my-zsh/themes/
51+# An empty array have no effect
52+# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
53+
54 # Uncomment the following line to use case-sensitive completion.
55 # CASE_SENSITIVE="true"
56