diff options
author | Marc Cornellà <marc.cornella@live.com> | 2020-02-19 19:32:28 +0100 |
---|---|---|
committer | Marc Cornellà <marc.cornella@live.com> | 2020-02-19 19:41:02 +0100 |
commit | f4b4a446aca37987bc2612d6115d156417628364 (patch) | |
tree | 7851b0ef5eb74c50a20c9b0d3a7f8eb48b9ee3fb /plugins/themes | |
parent | b297bf92964e04e24f960f4e38acdb9b740d2d9f (diff) | |
download | zsh-f4b4a446aca37987bc2612d6115d156417628364.tar.gz zsh-f4b4a446aca37987bc2612d6115d156417628364.tar.bz2 zsh-f4b4a446aca37987bc2612d6115d156417628364.zip |
Polish themes plugin and error out if theme not found
Diffstat (limited to 'plugins/themes')
-rw-r--r-- | plugins/themes/_theme | 3 | ||||
-rw-r--r-- | plugins/themes/themes.plugin.zsh | 29 |
2 files changed, 16 insertions, 16 deletions
diff --git a/plugins/themes/_theme b/plugins/themes/_theme deleted file mode 100644 index 8214ddb0d..000000000 --- a/plugins/themes/_theme +++ /dev/null @@ -1,3 +0,0 @@ -#compdef theme - -_arguments "1: :($(lstheme | tr "\n" " "))" diff --git a/plugins/themes/themes.plugin.zsh b/plugins/themes/themes.plugin.zsh index ac4ccc980..1fbde5b64 100644 --- a/plugins/themes/themes.plugin.zsh +++ b/plugins/themes/themes.plugin.zsh @@ -1,24 +1,27 @@ -function theme -{ - if [ -z "$1" ]; then - 1="random" - fi +function theme { + : ${1:=random} # Use random theme if none provided - if [ -f "$ZSH_CUSTOM/$1.zsh-theme" ] - then + if [[ -f "$ZSH_CUSTOM/$1.zsh-theme" ]]; then source "$ZSH_CUSTOM/$1.zsh-theme" - elif [ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ] - then + elif [[ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]]; then source "$ZSH_CUSTOM/themes/$1.zsh-theme" - else + elif [[ -f "$ZSH/themes/$1.zsh-theme" ]]; then source "$ZSH/themes/$1.zsh-theme" + else + echo "$0: Theme '$1' not found" + return 1 fi } -function lstheme -{ +function _theme { + _arguments "1: :($(lstheme))" +} + +compdef _theme theme + +function lstheme { # Resources: # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Modifiers # 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) } |