aboutsummaryrefslogtreecommitdiff
path: root/.vim/functions/pick-theme.vim
diff options
context:
space:
mode:
Diffstat (limited to '.vim/functions/pick-theme.vim')
-rw-r--r--.vim/functions/pick-theme.vim19
1 files changed, 19 insertions, 0 deletions
diff --git a/.vim/functions/pick-theme.vim b/.vim/functions/pick-theme.vim
new file mode 100644
index 0000000..e601a83
--- /dev/null
+++ b/.vim/functions/pick-theme.vim
@@ -0,0 +1,19 @@
+" PickTheme
+"
+" Pick a customized theme. If no specific theme is given, a random one will be
+" loaded instead.
+"
+" @param string name The name of the theme to load, if any.
+function PickTheme (...)
+ let name = get(a:, 1, "")
+
+ if name
+ exe "ru " . g:path . "/themes/" . name . ".vim"
+ return 0
+ endif
+
+ let s:themes = split(globpath(g:path . "/themes", "*.vim"), "\n")
+ let s:index = system("perl -e 'print int(rand(" . len(s:themes) . "))'")
+
+ exe "so " . s:themes[s:index]
+endfunction