From 899d9d5ab366706eaf80c504722a668e6c24ee3d Mon Sep 17 00:00:00 2001 From: Luke Lee Date: Fri, 3 Jun 2011 19:04:15 -0500 Subject: [PATCH] Default themes argument - This allows the function to be used from the shell as a shortcut to sourcing ~/.zshrc to load a new random theme - Refactor out list of all available themes --- lib/functions.zsh | 8 +++++++- oh-my-zsh.sh | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/functions.zsh b/lib/functions.zsh index 4dc946042..ce46f751d 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -86,7 +86,13 @@ function unlike_theme() { } function load_random_theme() { - themes=($*) + # Default theme selection + if [ $# -eq 0 ]; then + themes=($ZSH/themes/*zsh-theme) + else + themes=($*) + fi + N=${#themes[@]} ((N=(RANDOM%N)+1)) RANDOM_THEME=${themes[$N]} diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 5ea7fc089..6ffb9a2d3 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -42,13 +42,13 @@ export FAVORITE_THEMES_DIR="$ZSH/themes/favorites/" # Load the theme # Check for updates on initial load... if [ "$ZSH_THEME" = "random" ]; then - load_random_theme $ZSH/themes/*zsh-theme + load_random_theme elif [ "$ZSH_THEME" = "favorites" ]; then # Only randomize with liked themes if there are any if [ `ls $FAVORITE_THEMES_DIR | wc -w` -gt 0 ]; then load_random_theme $FAVORITE_THEMES_DIR/*zsh-theme else - load_random_theme $ZSH/themes/*zsh-theme + load_random_theme fi else source "$ZSH/themes/$ZSH_THEME.zsh-theme"