mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-05 01:46:46 +01:00
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.
This commit is contained in:
parent
d76258ff55
commit
6adad5c300
3 changed files with 27 additions and 32 deletions
10
themes/random.zsh-theme
Normal file
10
themes/random.zsh-theme
Normal file
|
|
@ -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..."
|
||||
Loading…
Add table
Add a link
Reference in a new issue