diff options
author | Willy Weiskopf <william@weiskopf.me> | 2014-07-16 22:21:09 -0600 |
---|---|---|
committer | Marc Cornellà <marc.cornella@live.com> | 2020-02-19 18:20:28 +0100 |
commit | 6adad5c300a6bfde33b593489cc1c3b645b721e8 (patch) | |
tree | ffc272716a4fce2ed12c4b833ff772a5f2e8067a /themes/random.zsh-theme | |
parent | d76258ff554ea58d9865b9864f5fff1dd8d2e4bb (diff) | |
download | zsh-6adad5c300a6bfde33b593489cc1c3b645b721e8.tar.gz zsh-6adad5c300a6bfde33b593489cc1c3b645b721e8.tar.bz2 zsh-6adad5c300a6bfde33b593489cc1c3b645b721e8.zip |
Move random theme functionality into "random" theme
The statements for selecting a random theme in oh-my-zsh.sh and the themes
plugin are duplicate. Most people eventually settle on a theme, making those
lines in oh-my-zsh.sh superfluous. To address those, it may makes sense to put
the random theme functionality into a theme of its own (since themes are just
zsh scripts.
Diffstat (limited to 'themes/random.zsh-theme')
-rw-r--r-- | themes/random.zsh-theme | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/themes/random.zsh-theme b/themes/random.zsh-theme new file mode 100644 index 000000000..739567662 --- /dev/null +++ b/themes/random.zsh-theme @@ -0,0 +1,10 @@ +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]} +source "$RANDOM_THEME" +echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..." |