mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-20 03:02:29 +01:00
theme-admin: Add support for pre-selecting random themes in a basic way.
This commit is contained in:
parent
3913106b2e
commit
20ab45218c
3 changed files with 25 additions and 2 deletions
11
oh-my-zsh.sh
11
oh-my-zsh.sh
|
|
@ -69,10 +69,19 @@ unset config_file
|
|||
|
||||
# Load the theme
|
||||
if [ "$ZSH_THEME" = "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))
|
||||
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"
|
||||
alias oh-my-zsh-theme-remove="echo 'Removing theme ${themes[$N]}' ; sed -i.old '/$(basename ${themes[$N]})/d' $THEMES_FILE"
|
||||
fi
|
||||
source "$RANDOM_THEME"
|
||||
echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
|
||||
else
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@ export ZSH=$HOME/.oh-my-zsh
|
|||
# Look in ~/.oh-my-zsh/themes/
|
||||
# Optionally, if you set this to "random", it'll load a random theme each
|
||||
# time that oh-my-zsh is loaded.
|
||||
# You may specify THEMES_FILE in case you want an specific set of themes
|
||||
# with it, oh-my-zsh-theme-remove will ease erasing the current theme
|
||||
# from the THEMES_FILE.
|
||||
# ls $ZSH/themes/*.zsh-theme | xargs -n1 basename > $THEMES_FILE
|
||||
# THEMES_FILE="$HOME/.omz-themes"
|
||||
ZSH_THEME="robbyrussell"
|
||||
|
||||
# Example aliases
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue