Restore custom dir hierarchy in theme plugin
Themes are now searched for in the following directories (in order): * $ZSH/custom/themes * $ZSH/custom * $ZSH/themes Search will always return first match found.
This commit is contained in:
parent
53c08153df
commit
730111f468
@ -1,23 +1,42 @@
|
|||||||
|
THEMEPATH=("$ZSH_CUSTOM/themes" "$ZSH_CUSTOM" "$ZSH/themes")
|
||||||
|
|
||||||
function theme
|
function theme
|
||||||
{
|
{
|
||||||
if [ -z "$1" ] || [ "$1" = "random" ]; then
|
if [ -z "$1" ] || [ "$1" = "random" ]; then
|
||||||
themes=($ZSH/themes/*zsh-theme)
|
# Load every theme in the themepath
|
||||||
|
# TODO remove the shadowed themes from the list
|
||||||
|
# i.e: if I have a custom theme foo overshadowing
|
||||||
|
# "$ZSH/themes/foo.zsh-theme", the latter shouldn't
|
||||||
|
# be part of this list.
|
||||||
|
themes=($(find $THEMEPATH -name '*.zsh-theme'))
|
||||||
|
|
||||||
N=${#themes[@]}
|
N=${#themes[@]}
|
||||||
((N=(RANDOM%N)+1))
|
((N=(RANDOM%N)+1))
|
||||||
RANDOM_THEME=${themes[$N]}
|
random_theme=${themes[$N]}
|
||||||
source "$RANDOM_THEME"
|
source "$random_theme"
|
||||||
echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
|
echo "[oh-my-zsh] Random theme '$random_theme' loaded."
|
||||||
else
|
else
|
||||||
if [ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]
|
theme_name="$1.zsh-theme"
|
||||||
|
match=""
|
||||||
|
for dir in $THEMEPATH
|
||||||
|
do
|
||||||
|
# Keep looking until we find a matching theme
|
||||||
|
if [ -f "$dir/$theme_name" ] && [ -z "$match" ]
|
||||||
|
then
|
||||||
|
match=$dir/$theme_name
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -n "$match" ]
|
||||||
then
|
then
|
||||||
source "$ZSH_CUSTOM/themes/$1.zsh-theme"
|
source "$match"
|
||||||
else
|
else
|
||||||
source "$ZSH/themes/$1.zsh-theme"
|
echo "[oh-my-zsh]Couldn't find theme $1."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function lstheme
|
function lstheme
|
||||||
{
|
{
|
||||||
find "$ZSH"/themes "$ZSH_CUSTOM"/themes -name '*.zsh-theme' | sort -u | sed 's:.*/\(.*\)\.zsh-theme:\1:'
|
find $THEMEPATH -name '*.zsh-theme' | sort -u | sed 's:.*/\(.*\)\.zsh-theme:\1:'
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user