summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobby Russell <robby@planetargon.com>2017-11-01 05:35:37 -0700
committerRobby Russell <robby@planetargon.com>2017-11-01 05:35:37 -0700
commita1d13aa0b4a794c4f10fdd9d69d59ce2d04c3785 (patch)
treea7b6415bc6ec305ec9caa9182eb48f573b7cbc4e
parentd848c94804918138375041a9f800f401bec12068 (diff)
parent5e77e00ad522a5d6a84067d22015b85b0080a19f (diff)
downloadzsh-a1d13aa0b4a794c4f10fdd9d69d59ce2d04c3785.tar.gz
zsh-a1d13aa0b4a794c4f10fdd9d69d59ce2d04c3785.tar.bz2
zsh-a1d13aa0b4a794c4f10fdd9d69d59ce2d04c3785.zip
Merge branch 'Random_Theme_From_List' of https://github.com/Gnouc/oh-my-zsh into Gnouc-Random_Theme_From_List
-rw-r--r--README.md8
-rw-r--r--oh-my-zsh.sh8
-rw-r--r--templates/zshrc.zsh-template7
3 files changed, 21 insertions, 2 deletions
diff --git a/README.md b/README.md
index 54107b1cb..fd4a0abc0 100644
--- a/README.md
+++ b/README.md
@@ -96,6 +96,14 @@ If you're feeling feisty, you can let the computer select one randomly for you e
ZSH_THEME="random" # (...please let it be pie... please be some pie..)
```
+And if you want to pick random theme from a list of your favorite themes:
+
+```shell
+ZSH_THEM_RANDOM_CANDIDATES=(
+ "robbyrussell"
+ "agnoster"
+)
+```
## Advanced Topics
diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh
index a7de646f2..7f78e4140 100644
--- a/oh-my-zsh.sh
+++ b/oh-my-zsh.sh
@@ -93,8 +93,12 @@ done
unset config_file
# Load the theme
-if [ "$ZSH_THEME" = "random" ]; then
- themes=($ZSH/themes/*zsh-theme)
+if [[ "$ZSH_THEME" == "random" ]]; then
+ if [[ "${(t)ZSH_THEME_RANDOM_CANDIDATES}" = "array" ]] && [[ "${#ZSH_THEME_RANDOM_CANDIDATES[@]}" -gt 0 ]]; then
+ themes=($ZSH/themes/${^ZSH_THEME_RANDOM_CANDIDATES}.zsh-theme)
+ else
+ themes=($ZSH/themes/*zsh-theme)
+ fi
N=${#themes[@]}
((N=(RANDOM%N)+1))
RANDOM_THEME=${themes[$N]}
diff --git a/templates/zshrc.zsh-template b/templates/zshrc.zsh-template
index af42e5b9f..966d7a975 100644
--- a/templates/zshrc.zsh-template
+++ b/templates/zshrc.zsh-template
@@ -9,6 +9,13 @@ export ZSH=$HOME/.oh-my-zsh
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
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/
+# An empty array have no effect
+# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
+
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"