aboutsummaryrefslogtreecommitdiff
path: root/.oh-my-zsh/plugins/themes
diff options
context:
space:
mode:
authorMarvin Borner2019-03-05 01:09:01 +0100
committerMarvin Borner2019-03-05 01:09:01 +0100
commit55457187d18221e76bd12f0fb2cfab65c49b92fb (patch)
tree8db042d2d80710d54100c2709ad4332153ac848a /.oh-my-zsh/plugins/themes
Initial commit
Diffstat (limited to '.oh-my-zsh/plugins/themes')
-rw-r--r--.oh-my-zsh/plugins/themes/README.md18
-rw-r--r--.oh-my-zsh/plugins/themes/_theme3
-rw-r--r--.oh-my-zsh/plugins/themes/themes.plugin.zsh26
3 files changed, 47 insertions, 0 deletions
diff --git a/.oh-my-zsh/plugins/themes/README.md b/.oh-my-zsh/plugins/themes/README.md
new file mode 100644
index 0000000..408e357
--- /dev/null
+++ b/.oh-my-zsh/plugins/themes/README.md
@@ -0,0 +1,18 @@
+# Themes Plugin
+
+This plugin allows you to change ZSH theme on the go.
+
+To use it, add `themes` to the plugins array in your zshrc file:
+
+```
+plugins=(... themes)
+```
+
+## Usage
+
+`theme <theme_name>` - Changes the ZSH theme to specified theme.
+
+`theme ` - Changes the ZSH theme to some random theme.
+
+`lstheme ` - Lists installed ZSH themes.
+
diff --git a/.oh-my-zsh/plugins/themes/_theme b/.oh-my-zsh/plugins/themes/_theme
new file mode 100644
index 0000000..8214ddb
--- /dev/null
+++ b/.oh-my-zsh/plugins/themes/_theme
@@ -0,0 +1,3 @@
+#compdef theme
+
+_arguments "1: :($(lstheme | tr "\n" " "))"
diff --git a/.oh-my-zsh/plugins/themes/themes.plugin.zsh b/.oh-my-zsh/plugins/themes/themes.plugin.zsh
new file mode 100644
index 0000000..2cd0ee3
--- /dev/null
+++ b/.oh-my-zsh/plugins/themes/themes.plugin.zsh
@@ -0,0 +1,26 @@
+function theme
+{
+ if [ -z "$1" ] || [ "$1" = "random" ]; then
+ themes=($ZSH/themes/*zsh-theme)
+ N=${#themes[@]}
+ ((N=(RANDOM%N)+1))
+ RANDOM_THEME=${themes[$N]}
+ source "$RANDOM_THEME"
+ echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
+ else
+ if [ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]
+ then
+ source "$ZSH_CUSTOM/themes/$1.zsh-theme"
+ else
+ source "$ZSH/themes/$1.zsh-theme"
+ fi
+ fi
+}
+
+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)
+}