aboutsummaryrefslogtreecommitdiff
path: root/.vim/functions/pick-theme.vim
blob: 6160e92e02aea489ff4a7dd6b7829699c101cf9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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 !empty(name)
		exe "so " . 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