themes.plugin.zsh 793 Bytes
Newer Older
1
2
function theme {
    : ${1:=random} # Use random theme if none provided
3

4
    if [[ -f "$ZSH_CUSTOM/$1.zsh-theme" ]]; then
5
        source "$ZSH_CUSTOM/$1.zsh-theme"
6
    elif [[ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]]; then
7
        source "$ZSH_CUSTOM/themes/$1.zsh-theme"
8
    elif [[ -f "$ZSH/themes/$1.zsh-theme" ]]; then
9
        source "$ZSH/themes/$1.zsh-theme"
10
11
12
    else
        echo "$0: Theme '$1' not found"
        return 1
Roey Darwish Dror's avatar
Roey Darwish Dror committed
13
14
15
    fi
}

16
17
18
19
20
21
22
function _theme {
    _arguments "1: :($(lstheme))"
}

compdef _theme theme

function lstheme {
23
24
25
    # Resources:
    # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Modifiers
    # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Qualifiers
26
    print "$ZSH_CUSTOM"/*.zsh-theme(N:t:r) {"$ZSH_CUSTOM","$ZSH"}/themes/*.zsh-theme(N:t:r)
Roey Darwish Dror's avatar
Roey Darwish Dror committed
27
}