6f7d51c68d4de102f295d3b543ccb5c61dea2c3c

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

Message

Feature: Random themes now supported. Just set your theme to 'random' and it'll load a different theme each time oh-my-zsh is started. Closes #309

Diff

 1diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh
 2index 291772dfe0b8bc5345717ef2b185eb7b52fa3194..1e735b058437841b83500f0e380f60bef7ae985b 100644
 3--- a/oh-my-zsh.sh
 4+++ b/oh-my-zsh.sh
 5@@ -15,7 +15,19 @@ plugin=${plugin:=()}
 6 for plugin ($plugins) source $ZSH/plugins/$plugin/$plugin.plugin.zsh
 7 
 8 # Load the theme
 9-source "$ZSH/themes/$ZSH_THEME.zsh-theme"
10+# Check for updates on initial load...
11+if [ "$ZSH_THEME" = "random" ]
12+then
13+  themes=($ZSH/themes/*zsh-theme)
14+  N=${#themes[@]}
15+  ((N=RANDOM%N))
16+  RANDOM_THEME=${themes[$N]}
17+  source "$RANDOM_THEME"
18+  echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
19+else
20+  source "$ZSH/themes/$ZSH_THEME.zsh-theme"
21+fi
22+
23 
24 # Check for updates on initial load...
25 if [ "$DISABLE_AUTO_UPDATE" = "true" ]
26diff --git a/templates/zshrc.zsh-template b/templates/zshrc.zsh-template
27index 506daa9a2489c0ac7a107d4f7f96ff320717b9af..576d45eaaadd7bc09533c73c3547f222b33b4fab 100644
28--- a/templates/zshrc.zsh-template
29+++ b/templates/zshrc.zsh-template
30@@ -1,8 +1,10 @@
31 # Path to your oh-my-zsh configuration.
32 export ZSH=$HOME/.oh-my-zsh
33 
34-# Set to the name theme to load.
35+# Set name of the theme to load.
36 # Look in ~/.oh-my-zsh/themes/
37+# Optionally, if you set this to "random", it'll load a random theme each
38+# time that oh-my-zsh is loaded.
39 export ZSH_THEME="robbyrussell"
40 
41 # Set to this to use case-sensitive completion