f4b4a446aca37987bc2612d6115d156417628364
- Author
- Marc Cornellà <marc.cornella@live.com>
- Committer
- Marc Cornellà <marc.cornella@live.com>
- Date
Message
Polish themes plugin and error out if theme not found
Diff
1diff --git a/plugins/themes/_theme b/plugins/themes/_theme
2deleted file mode 100644
3index 8214ddb0dd14f3e996da7f678140a1c913e45430..0000000000000000000000000000000000000000
4--- a/plugins/themes/_theme
5+++ /dev/null
6@@ -1,3 +0,0 @@
7-#compdef theme
8-
9-_arguments "1: :($(lstheme | tr "\n" " "))"
10diff --git a/plugins/themes/themes.plugin.zsh b/plugins/themes/themes.plugin.zsh
11index ac4ccc980297d7f2878f453ac082c342db8aa673..1fbde5b6463565ad2925aad780ac6fbfd25cc18f 100644
12--- a/plugins/themes/themes.plugin.zsh
13+++ b/plugins/themes/themes.plugin.zsh
14@@ -1,24 +1,27 @@
15-function theme
16-{
17- if [ -z "$1" ]; then
18- 1="random"
19- fi
20+function theme {
21+ : ${1:=random} # Use random theme if none provided
22
23- if [ -f "$ZSH_CUSTOM/$1.zsh-theme" ]
24- then
25+ if [[ -f "$ZSH_CUSTOM/$1.zsh-theme" ]]; then
26 source "$ZSH_CUSTOM/$1.zsh-theme"
27- elif [ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]
28- then
29+ elif [[ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]]; then
30 source "$ZSH_CUSTOM/themes/$1.zsh-theme"
31- else
32+ elif [[ -f "$ZSH/themes/$1.zsh-theme" ]]; then
33 source "$ZSH/themes/$1.zsh-theme"
34+ else
35+ echo "$0: Theme '$1' not found"
36+ return 1
37 fi
38 }
39
40-function lstheme
41-{
42+function _theme {
43+ _arguments "1: :($(lstheme))"
44+}
45+
46+compdef _theme theme
47+
48+function lstheme {
49 # Resources:
50 # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Modifiers
51 # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Qualifiers
52- print -l {$ZSH,$ZSH_CUSTOM}/themes/*.zsh-theme(N:t:r)
53+ print "$ZSH_CUSTOM"/*.zsh-theme(N:t:r) {"$ZSH_CUSTOM","$ZSH"}/themes/*.zsh-theme(N:t:r)
54 }