1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-12-25 05:41:58 +00:00

Add blacklist variable for random theme

Co-authored-by: Fran Garcia <fran.miranda@gmail.com>
This commit is contained in:
Marc Cornellà 2020-02-19 19:53:37 +01:00
parent f4b4a446ac
commit 3d4890dcc0

View file

@ -5,19 +5,23 @@ if [[ "${(t)ZSH_THEME_RANDOM_CANDIDATES}" = array && ${#ZSH_THEME_RANDOM_CANDIDA
# Use ZSH_THEME_RANDOM_CANDIDATES if properly defined # Use ZSH_THEME_RANDOM_CANDIDATES if properly defined
themes=($ZSH_THEME_RANDOM_CANDIDATES) themes=($ZSH_THEME_RANDOM_CANDIDATES)
else else
# Look for themes in $ZSH_CUSTOM and $ZSH and add only the theme name (:t) # Look for themes in $ZSH_CUSTOM and $ZSH and add only the theme name
themes=( themes=(
"$ZSH_CUSTOM"/*.zsh-theme(N:t:r) "$ZSH_CUSTOM"/*.zsh-theme(N:t:r)
"$ZSH_CUSTOM"/themes/*.zsh-theme(N:t:r) "$ZSH_CUSTOM"/themes/*.zsh-theme(N:t:r)
"$ZSH"/themes/*.zsh-theme(N:t:r) "$ZSH"/themes/*.zsh-theme(N:t:r)
) )
# Remove blacklisted themes from the list
for theme in ${ZSH_THEME_RANDOM_BLACKLIST[@]}; do
themes=("${(@)themes:#$theme}")
done
fi fi
# Choose a theme out of the pool of candidates # Choose a theme out of the pool of candidates
N=${#themes[@]} N=${#themes[@]}
(( N = (RANDOM%N) + 1 )) (( N = (RANDOM%N) + 1 ))
RANDOM_THEME="${themes[$N]}" RANDOM_THEME="${themes[$N]}"
unset N themes unset N themes theme
# Source theme # Source theme
if [[ -f "$ZSH_CUSTOM/$RANDOM_THEME.zsh-theme" ]]; then if [[ -f "$ZSH_CUSTOM/$RANDOM_THEME.zsh-theme" ]]; then