summaryrefslogtreecommitdiffstats
path: root/.config/zsh/oh-my-zsh/themes/random.zsh-theme
diff options
context:
space:
mode:
authorLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2025-02-13 14:13:49 +0530
committerLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2025-02-13 14:13:49 +0530
commit8a2e1006b3b272126332aa064f3ad95387129544 (patch)
tree944c80ac612a65980d94a54ba11b6c7102037ecf /.config/zsh/oh-my-zsh/themes/random.zsh-theme
parentdcbb16d8b08ff5956abef5e6478b59df2e93ad35 (diff)
downloaddotfiles-8a2e1006b3b272126332aa064f3ad95387129544.tar.gz
dotfiles-8a2e1006b3b272126332aa064f3ad95387129544.tar.bz2
dotfiles-8a2e1006b3b272126332aa064f3ad95387129544.zip
new dot filesHEADmaster
Diffstat (limited to '.config/zsh/oh-my-zsh/themes/random.zsh-theme')
-rw-r--r--.config/zsh/oh-my-zsh/themes/random.zsh-theme47
1 files changed, 47 insertions, 0 deletions
diff --git a/.config/zsh/oh-my-zsh/themes/random.zsh-theme b/.config/zsh/oh-my-zsh/themes/random.zsh-theme
new file mode 100644
index 0000000..28af84e
--- /dev/null
+++ b/.config/zsh/oh-my-zsh/themes/random.zsh-theme
@@ -0,0 +1,47 @@
+# Deprecate ZSH_THEME_RANDOM_BLACKLIST
+if [[ -n "$ZSH_THEME_RANDOM_BLACKLIST" ]]; then
+ echo '[oh-my-zsh] ZSH_THEME_RANDOM_BLACKLIST is deprecated. Use `ZSH_THEME_RANDOM_IGNORED` instead.'
+ ZSH_THEME_RANDOM_IGNORED=($ZSH_THEME_RANDOM_BLACKLIST)
+ unset ZSH_THEME_RANDOM_BLACKLIST
+fi
+
+# Make themes a unique array
+typeset -Ua themes
+
+if [[ "${(t)ZSH_THEME_RANDOM_CANDIDATES}" = array && ${#ZSH_THEME_RANDOM_CANDIDATES[@]} -gt 0 ]]; then
+ # Use ZSH_THEME_RANDOM_CANDIDATES if properly defined
+ themes=(${(@)ZSH_THEME_RANDOM_CANDIDATES:#random})
+else
+ # Look for themes in $ZSH_CUSTOM and $ZSH and add only the theme name
+ themes=(
+ "$ZSH_CUSTOM"/*.zsh-theme(N:t:r)
+ "$ZSH_CUSTOM"/themes/*.zsh-theme(N:t:r)
+ "$ZSH"/themes/*.zsh-theme(N:t:r)
+ )
+ # Remove ignored themes from the list
+ for theme in random ${ZSH_THEME_RANDOM_IGNORED[@]}; do
+ themes=("${(@)themes:#$theme}")
+ done
+fi
+
+# Choose a theme out of the pool of candidates
+N=${#themes[@]}
+(( N = (RANDOM%N) + 1 ))
+RANDOM_THEME="${themes[$N]}"
+unset N themes theme
+
+# Source theme
+if [[ -f "$ZSH_CUSTOM/$RANDOM_THEME.zsh-theme" ]]; then
+ source "$ZSH_CUSTOM/$RANDOM_THEME.zsh-theme"
+elif [[ -f "$ZSH_CUSTOM/themes/$RANDOM_THEME.zsh-theme" ]]; then
+ source "$ZSH_CUSTOM/themes/$RANDOM_THEME.zsh-theme"
+elif [[ -f "$ZSH/themes/$RANDOM_THEME.zsh-theme" ]]; then
+ source "$ZSH/themes/$RANDOM_THEME.zsh-theme"
+else
+ echo "[oh-my-zsh] Random theme '${RANDOM_THEME}' not found"
+ return 1
+fi
+
+if [[ "$ZSH_THEME_RANDOM_QUIET" != true ]]; then
+ echo "[oh-my-zsh] Random theme '${RANDOM_THEME}' loaded"
+fi