Commit f4b4a446 authored by Marc Cornellà's avatar Marc Cornellà
Browse files

Polish themes plugin and error out if theme not found

parent b297bf92
#compdef theme
_arguments "1: :($(lstheme | tr "\n" " "))"
function theme function theme {
{ : ${1:=random} # Use random theme if none provided
if [ -z "$1" ]; then
1="random"
fi
if [ -f "$ZSH_CUSTOM/$1.zsh-theme" ] if [[ -f "$ZSH_CUSTOM/$1.zsh-theme" ]]; then
then
source "$ZSH_CUSTOM/$1.zsh-theme" source "$ZSH_CUSTOM/$1.zsh-theme"
elif [ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ] elif [[ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]]; then
then
source "$ZSH_CUSTOM/themes/$1.zsh-theme" source "$ZSH_CUSTOM/themes/$1.zsh-theme"
else elif [[ -f "$ZSH/themes/$1.zsh-theme" ]]; then
source "$ZSH/themes/$1.zsh-theme" source "$ZSH/themes/$1.zsh-theme"
else
echo "$0: Theme '$1' not found"
return 1
fi fi
} }
function lstheme function _theme {
{ _arguments "1: :($(lstheme))"
}
compdef _theme theme
function lstheme {
# Resources: # Resources:
# http://zsh.sourceforge.net/Doc/Release/Expansion.html#Modifiers # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Modifiers
# http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Qualifiers # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Qualifiers
print -l {$ZSH,$ZSH_CUSTOM}/themes/*.zsh-theme(N:t:r) print "$ZSH_CUSTOM"/*.zsh-theme(N:t:r) {"$ZSH_CUSTOM","$ZSH"}/themes/*.zsh-theme(N:t:r)
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment