From 9a3fc33caa0385bfcbd73402b8691cb960326216 Mon Sep 17 00:00:00 2001 From: UnaTried <103455203+UnaTried@users.noreply.github.com> Date: Wed, 2 Apr 2025 19:05:13 +0200 Subject: [PATCH] Made the theme selecting more "modular". It now downloads a new default (theme) if it doesn't exist, then that default gets automatically sourced. --- oh-my-zsh.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 952405c19..198982b05 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -220,7 +220,7 @@ is_theme() { is_default_theme() { local base_dir=$1 - builtin test -f $base_dir + builtin test -d $base_dir } if [[ -n "$ZSH_THEME" ]]; then @@ -232,10 +232,19 @@ if [[ -n "$ZSH_THEME" ]]; then source "$ZSH/themes/$ZSH_THEME.zsh-theme" else echo "[oh-my-zsh] Theme '$ZSH_THEME' was not found, using default theme!" - if is_default_theme "$ZSH_CUSTOM"; then - source "$ZSH_CUSTOM/robbyrussell.zsh-theme" - elif is_default_theme "$ZSH_CUSTOM/themes"; then - source "$ZSH_CUSTOM/themes/robbyrussell.zsh-theme" + if is_default_theme "$ZSH_CUSTOM" && ! is_theme "$ZSH_THEME" "robbyrussell"; then + if is_theme "$ZSH_CUSTOM/themes/" "robbyrussell"; then + source "$ZSH_CUSTOM/themes/robbyrussell.zsh-theme" + else + echo "[oh-my-zsh] The default theme (robbyrussell) was not found, redownloading it!" + if ! command -v curl &> /dev/null; then + wget -qO $ZSH_CUSTOM/themes/robbyrussell.zsh-theme https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/refs/heads/master/themes/robbyrussell.zsh-theme + source "$ZSH_CUSTOM/robbyrussell.zsh-theme" + else + curl -s -o $ZSH_CUSTOM/themes/robbyrussell.zsh-theme https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/refs/heads/master/themes/robbyrussell.zsh-theme + source "$ZSH_CUSTOM/themes/robbyrussell.zsh-theme" + fi + fi elif is_default_theme "$ZSH/themes"; then source "$ZSH/themes/robbyrussell.zsh-theme" else