2020-02-19 19:32:28 +01:00
|
|
|
function theme {
|
|
|
|
: ${1:=random} # Use random theme if none provided
|
2014-07-17 06:21:09 +02:00
|
|
|
|
2020-02-19 19:32:28 +01:00
|
|
|
if [[ -f "$ZSH_CUSTOM/$1.zsh-theme" ]]; then
|
2014-07-17 06:21:09 +02:00
|
|
|
source "$ZSH_CUSTOM/$1.zsh-theme"
|
2020-02-19 19:32:28 +01:00
|
|
|
elif [[ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]]; then
|
2014-07-17 06:21:09 +02:00
|
|
|
source "$ZSH_CUSTOM/themes/$1.zsh-theme"
|
2020-02-19 19:32:28 +01:00
|
|
|
elif [[ -f "$ZSH/themes/$1.zsh-theme" ]]; then
|
2014-07-17 06:21:09 +02:00
|
|
|
source "$ZSH/themes/$1.zsh-theme"
|
2020-02-19 19:32:28 +01:00
|
|
|
else
|
|
|
|
echo "$0: Theme '$1' not found"
|
|
|
|
return 1
|
2012-06-22 19:25:44 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-02-19 19:32:28 +01:00
|
|
|
function _theme {
|
|
|
|
_arguments "1: :($(lstheme))"
|
|
|
|
}
|
|
|
|
|
|
|
|
compdef _theme theme
|
|
|
|
|
|
|
|
function lstheme {
|
2018-10-08 18:25:20 +02:00
|
|
|
# Resources:
|
|
|
|
# http://zsh.sourceforge.net/Doc/Release/Expansion.html#Modifiers
|
|
|
|
# http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Qualifiers
|
2020-03-23 22:50:06 +01:00
|
|
|
{
|
|
|
|
# Show themes inside $ZSH_CUSTOM (in any subfolder)
|
|
|
|
# Strip $ZSH_CUSTOM/themes/ and $ZSH_CUSTOM/ from the name, so that it matches
|
|
|
|
# the value that should be written in $ZSH_THEME to load the theme.
|
2020-04-05 17:14:48 +02:00
|
|
|
print -l "$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::)
|
2020-03-23 22:50:06 +01:00
|
|
|
|
|
|
|
# Show themes inside $ZSH, stripping the head of the path.
|
|
|
|
print -l "$ZSH"/themes/*.zsh-theme(.N:t:r)
|
|
|
|
} | sort -u | fmt -w $COLUMNS
|
2012-06-22 19:25:44 +02:00
|
|
|
}
|