1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-09-24 17:00:47 +00:00

Polish themes plugin and error out if theme not found

This commit is contained in:
Marc Cornellà 2020-02-19 19:32:28 +01:00
parent b297bf9296
commit f4b4a446ac
2 changed files with 16 additions and 16 deletions

View file

@ -1,3 +0,0 @@
#compdef theme
_arguments "1: :($(lstheme | tr "\n" " "))"

View file

@ -1,24 +1,27 @@
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)
} }