Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Ohmyzsh
Commits
f4b4a446
Commit
f4b4a446
authored
Feb 19, 2020
by
Marc Cornellà
Browse files
Polish themes plugin and error out if theme not found
parent
b297bf92
Changes
2
Hide whitespace changes
Inline
Side-by-side
plugins/themes/_theme
deleted
100644 → 0
View file @
b297bf92
#compdef theme
_arguments "1: :($(lstheme | tr "\n" " "))"
plugins/themes/themes.plugin.zsh
View file @
f4b4a446
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"
el
se
el
if
[[
-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
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment