theme-admin: Add support for pre-selecting random themes in a basic way.

This commit is contained in:
Javier Domingo Cansino 2014-06-23 18:19:21 +02:00
commit 20ab45218c
3 changed files with 25 additions and 2 deletions

View file

@ -1,10 +1,19 @@
function theme
{
if [ -z "$1" ] || [ "$1" = "random" ]; then
themes=($ZSH/themes/*zsh-theme)
if [ -f "$THEMES_FILE" ]; then
echo "[oh-my-zsh] Found custom theme file $THEMES_FILE"
themes=($(<$THEMES_FILE))
alias oh-my-zsh-theme-remove='echo "Removing theme ${themes[$N]}" ; sed -i.old "/$(basename ${themes[$N]})/d" $THEMES_FILE'
else
themes=($ZSH/themes/*zsh-theme)
fi
N=${#themes[@]}
((N=(RANDOM%N)+1))
RANDOM_THEME=${themes[$N]}
if [ -f "$THEMES_FILE" ]; then
RANDOM_THEME="$ZSH/themes/$RANDOM_THEME"
fi
source "$RANDOM_THEME"
echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
else