Skip to content

Commit

Permalink
Merge branch 'Random_Theme_From_List' of https://github.com/Gnouc/oh-…
Browse files Browse the repository at this point in the history
…my-zsh into Gnouc-Random_Theme_From_List
  • Loading branch information
robbyrussell committed Nov 1, 2017
2 parents d848c94 + 5e77e00 commit a1d13aa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions oh-my-zsh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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]}
Expand Down
7 changes: 7 additions & 0 deletions templates/zshrc.zsh-template
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit a1d13aa

Please sign in to comment.